How to Get a Specific Value from Lookupset Function - ssrs-2008

My data Report like this,
ID Name
1 Abc
2 Abc
3 Abc
4 Abc
=Join(LookUpSet(Fields!name.Value,Fields!name.Value,Fields!ID.Value,
"Dataset1",",")
After Using LookupSet function I'm Getting Value as
ID Name
1,2,3,4 Abc
Code.GetUrl(Join(LookUpSet(Fields!ID.Value,Fields!ID.Value,
Fields!ID.Value,"Dataset1"),""))
This Above code is to set HyperLink, code.GetUrl() returs a hyperlink with the Id, but I cant Get Particular ID in the link. Getting just ID 1 for All the Id's link..........
Kindly Help......

Did you miss a parentheses in this line?
Join(LookUpSet(Fields!name.Value,Fields!name.Value,Fields!ID.Value,
"Dataset1"),",")
And you missed a , in the next line?
Code.GetUrl(Join(LookUpSet(Fields!ID.Value,Fields!ID.Value,
Fields!ID.Value,"Dataset1"),","))

Related

I need to change the output of a query so that instead of it coming back as the abbreviation 'em' it says 'employee'. Tsql

I have the correct result coming back. I just need to convert 6 abbreviations in that result to their correct names. There are 20k names assigned to 1 of 6 abbreviated names.
I tried aliasing but that seems to only work for table names.
I tried doing a case statement but that didn't work.
You need to provide more details (like some sample input and output), but if you have data like EM100, and you want to make it EMPLOYEE 100, then you could use an expression such as:
CASE WHEN ColumnName like 'EM%' THEN 'EMPLOYEE ' + SUBSTRING (ColumnName,3,100)
WHEN ColumnName like 'RN%' THEN 'REGNURSE' + SUBSTRING (ColumnName,3,100)
else ColumnName END
But providing more details will help provide a more specific answer.

How to reach the end of a chain of cells

I have a file with two sheets:
sheet_A
A B
1 Mr. Joe USD
sheet_B
A B
1 =sheet_A.A1 ???
sheet_B.B1 shall show the value USD. I know i could get it easily with =sheet_A.B1 but I do not want that.
If I enter into sheet_B.B1 =ADDRESS(ROW();COLUMN()-1) I get the output $C$1 and with =INDIRECT(ADDRESS(ROW();COLUMN()-1)) Mr. Joe.
How can I "navigate" through a chain sheet_B.B1 - sheet_B.A1 - sheet_A.A1 - sheet_A.B1?
Edit 1
Maybe I need something like this
=OFFSET(FORMULA(ADDRESS(ROW();COLUMN()-1);0;1)#
sheet_B.B2 shall show the content of sheet_A.B2 in relation of the value in sheet_B.A1
Here are two possibilities. Either formula produces USD in sheet_B.B1.
=INDIRECT(ADDRESS(ROW();COLUMN();;;"sheet_A"))
=VLOOKUP(A1;$sheet_A.A1:B1;2)
Documentation: ADDRESS, VLOOKUP.
EDIT:
One more idea: The following produces the string "=sheet_A.A1", which could be parsed for the sheet name and cell address. Perhaps you would like to use it to refer to sheet_A.B1.
=FORMULA(INDIRECT(ADDRESS(ROW();COLUMN()-1)))
However, as I commented, there is probably an easier way for what you are trying to accomplish.
Documentation: FORMULA.
EDIT 2:
Here is the formula you requested. It uses REPLACE to remove = at the beginning of the string.
=OFFSET(INDIRECT(REPLACE(FORMULA(INDIRECT(ADDRESS(ROW();COLUMN()-1)));1;1;""));0;1)

kdb+/q: Prevent initialised tables from returning a comma

Consider the following example:
test:([] name:`symbol$(); secondColumn:`int$());
insert[`test;(`John;1)];
myvar:exec name from test;
Now myvar is now:
q)myvar
,`John
So to select the actual result, I have to do:
q)myvar[0]
`John
I understand this is because of the initialisation, so is there a way to make myvar contain the actual value immediately?
Array access with [0] or first is the correct way if you want an "atomic" variable.
myvar:first exec name from test;
A list with a single element in KDB can be created in multiple ways (which is something you are getting in myvar)
q)enlist `John
,`John
q)(),`John
,`John
A KDB table is basically a flip of a dictionary of lists.
`name`secondColumn!(`John`James;1 2) /Dictionary of lists
name | John James
secondColumn| 1 2
q)test2:flip `name`secondColumn!(`John`James;1 2)
name secondColumn
------------------
John 1
James 2
Both of the following commands achieve the same results :
q)exec name from test2
q)test2[`name]
`John`James
When you selected the test column using the exec command it returned all the elements of the list (a list with one element)
Apart from the ways explained in the accepted answer, there are few more ways (slightly different however) you can get the first element returned from the table.
q)exec name[0] from test
q)test[`name][0]
q)exec first name from test

Crystal Reports - formatting the output

I am working with Crystal reports 12. My command returns the results as follows
(Sorry for using text delimited with "|" symbol, I am not allowed to use images since I have not enough reputation points)
StartDate|EndDate|UID|Subject|EmpCode|EmpName|TestCode|TestName|TestMethod
2014-02-02|2014-02-02|01|Plan name 1|E0001|Employee 1|TST01|Test Name 1|Test Method 1
2014-02-02|2014-02-02|01|Plan name 1|E0001|Employee 2|TST01|Test Name 1|Test Method 1
2014-02-02|2014-02-02|01|Plan name 1|E0001|Employee 3|TST01|Test Name 1|Test Method 1
2014-02-02|2014-02-02|01|Plan name 1|E0001|Employee 1|TST01|Test Name 2|Test Method 2
2014-02-02|2014-02-02|01|Plan name 1|E0001|Employee 2|TST01|Test Name 2|Test Method 2
2014-02-02|2014-02-02|01|Plan name 1|E0001|Employee 3|TST01|Test Name 2|Test Method 2
I want to make a report from this results that looks something similar to the following..
2014-02-02|2014-02-02|01|Plan name 1
TST01|Test Name 1|Test Method 1
TST01|Test Name 2|Test Method 2
E0001|Employee 1
E0001|Employee 2
E0001|Employee 3
How can I achieve this, any help?
Thanks,
JKV
Create 3 groups
1. create with `plane name1` of use the combination of `2014-02-02|2014-02-02|01|Plan name 1` and place the 3 fields in group header1
2. Similar way group the second group as `TST01` or combination of `TST01|Test Name 1|Test Method 1` and place 3 fileds in groupheader2
3. now make another group 3 with `E0001`
4. Place the filed with `E0001` and `employee1 or 2 or 3` in detail section and refresh the report.

Display table field through query using form

Just some background information. My table, (HireHistory) has 50 columns in it (horizontal). I have a Form (HireHistoryForm) which has a 2 text boxes (HistoryMovieID and HistoryCustomerID) and a button (the button runs the query 'HireHistoryQuery')
Here's an excerpt of my data (the CustomerID's are along the top):
So what I need is so that if a number is entered into the HistoryCustomerID box, then it displays that column. e.g. if the value entered is '1', then in my query it will show all records from column 1.
If a number is entered into the HistoryMovieID box (e.g. 0001) then it displays all instances of that MovieID for the specific CustomerID's. i.e. In column 1 is the ID's, so for ID=1 it will show "0001 on 19/05/2006" then will go on to find the next instance of '0001' etc.
For the HistoryCustomerID I tried to put this into my 'Field' for the query:
=[Forms]![HireHistoryForm]![HistoryCustomerID]
But it didn't work. My query just returned a column labelled '10' and the rows were just made up of '10'.
If you could help I'd greatly appreciate it. :)
No offense intended (or as little as possible, anyway), but that is a horrible way to structure your data. You really need to restructure it like this:
CustomerID MovieID HireDate
---------- ------- --------
1 0001 19/05/2006
1 0003 20/10/2003
1 0007 13/08/2003
...
2 0035 16/08/2012
2 0057 06/10/2012
...
If you keep your current data structure then
You'll go mad, and
It's extremely unlikely that anyone else will go anywhere near this problem.
Edit
Your revised data structure is a very slight improvement, but it still works against you. Consider that in your other question here you are essentially asking for a way to "fix" your data structure "on the fly" when you do a query.
The good news is that you can run a bit of VBA code once to convert your data structure to something workable. Start by creating your new table, which I'll call "HireHistoryV2"
ID - AutoNumber, Primary Key
CustomerID - Number(Long Integer), Indexed (duplicates OK)
MovieID - Text(4), Indexed (duplicates OK)
HireDate - Date/Time, Indexed (duplicates OK)
The VBA code to copy your data to the new table would look something like this:
Function RestructureHistory()
Dim cdb As DAO.Database, rstIn As DAO.Recordset, rstOut As DAO.Recordset
Dim fld As DAO.Field, a() As String
Set cdb = CurrentDb
Set rstIn = cdb.OpenRecordset("HireHistory", dbOpenTable)
Set rstOut = cdb.OpenRecordset("HireHistoryV2", dbOpenTable)
Do While Not rstIn.EOF
For Each fld In rstIn.Fields
If fld.Name Like "Hire*" Then
If Not IsNull(fld.Value) Then
a = Split(fld.Value, " on ", -1, vbBinaryCompare)
rstOut.AddNew
rstOut!CustomerID = rstIn!CustomerID
rstOut!MovieID = a(0)
rstOut!HireDate = CDate(a(1))
rstOut.Update
End If
End If
Next
Set fld = Nothing
rstIn.MoveNext
Loop
rstOut.Close
Set rstOut = Nothing
rstIn.Close
Set rstIn = Nothing
Set cdb = Nothing
MsgBox "Done!"
End Function
Note: You appear to be using dd/mm/yyyy date formatting, so check the date conversions carefully to make sure that they converted properly.