Hi Team,
I have a SSRS report like this, the users would like to see the data like the picture below. For Column 2 if the value is N/A the values of column 3 would be in list and separated by comma. and the multiple lines will be converted to only one line where N/A is there.
First you will want to create row groups for two of your columns. I have assumed they're called Shipment and Description. Then you can use Join and LookupSet to do the CSV aggregation. Similar to the answer here.
Something like this:
=Join(LookupSet(Fields!Shipment.Value & "-" & Fields!Description.Value,
Fields!Shipment.Value & "-" & Fields!Description.Value,
Fields!PartNumber.Value, "YourDataset"), ",")
Related
I am in report builder and I have my primary dataset that is from a SQL database, I also then created a second dataset (enter data). I need to compare 2 fields from each dataset to retrieve the correct value from the 2nd dataset and populate a column on my report. I have tried the IIF statements and Lookup statements but I keep getting the error "report item expressions can only refer to fields within the current dataset".
I have a attached a screenshot of what I am trying to do....
The IIF statement I tried to use.. If Acctnum and prodid = each other return IncodeNumber
=IIF((Fields!AcctNum.Value=Fields!AcctNum.Value, "IncodeAccount") AND
(Fields!ProdId.Value =Fields!ProdId.Value, "IncodeAccount")),(Fields!IncodeNumber.Value, "IncodeAccount"),"True")
See code in my problem.
You need to use LOOKUP(). The problem with LOOKUP() is that is can only compare a single value from each dataset. However, we can easily get around this issue by concatenating the two values you need to compare.
Note: This assumes the expression will be in a tablix that is bound to your first dataset and that IncodeAccount is your second dataset - the values you want to lookup. If this is not the case just adjust the expression accordingly
So for you, you probably need to do something like this..
=LOOKUP(
Fields!AcctNum.Value & "||" & Fields!ProdId.Value,
Fields!AcctNum.Value & "||" & Fields!ProdId.Value,
Fields!IncodeNumber.Value,
"IncodeAccount"
)
I've used two pipe symbols to join the values to avoid incorrect matches being found. e.g. Account 123 and product ID 4567 would incorrectly match to Account 1234 and product ID 567 as they would both be 1234567 when joined. By using the || the match would be 123||4567 and 1234||567 respectively.
You may need to convert the values to string using CStr()
Alternative approach
If you are going to do this 'join' multiple times in the same dataset then you could add a calculated column to the dataset that concatenates the two columns. Then you can use this single field in the lookup which will make things a little simpler.
Or, you could do this concatenation in a database view which would make things even easier.
I have a table as shown below:
Table 1
I need to display data like below. I have tried using grouping but but i failed.
I have read some topics but can't find the solution. This should not be that hard.
Table 2
You can get that using LookupSet over a dumb group.
Add a tablix to your report and add a parent group in the Row Groups pane.
Use the below expression to create the group.
=1
That expression will create only one group, and you will have something like this in design.
Then use this expression in the highlighted cell in my screenshot above.
=join(
LookupSet(1,1,Fields!ColumnA.Value,"DataSetName")," - ")
Where Fields!ColumnA.Value is the field of X, Y and Z values, and DataSetName should be the name of your dataset.
You will get this result.
If you have repeated values in ColumnA they will appear repeated too in the cell. You will have to filter your dataset to get only unique values.
Is it possible to have a dynamic link within a lookupset function in SSRS?
I am joining several values from one Dataset to another using the Lookupset & join functions. Would it be possible for each value returned to point to a different URL address based on the value selected?
For example, I am using this function to return Tasks as a 1 to many relationship with their relevant projects:
=Join(LookupSet(Fields!Title.Value, Fields!Related_Project.Value, Fields!Title.Value, "TeamTasks"), Environment.NewLine() & Environment.NewLine())
For the returning values, is it possible to link them to their respective URL?
When I set the the expression for Hyperlink as follows:
="https://example/" & Fields!ID.Value
or
= "https://example/" & Lookup(Fields!Title.Value, Fields!Related_Project.Value, Fields!ID.Value, "TeamTasks")
It simply works for the first returned value and is not dynamic within the Lookupset function.
An example of the table would be:
Project Title Task
_____________ _____
Project 1 Task1
Task2
Task3
_____________ _____
Project 2 Task 1
Ideally, for each separate Task clicked, it will link you to the respective URL.
The Task column is populated via the Lookupset function within the same Row as Project.
Is there any way to fix this?
Thanks in advance!
One TextBox can points to only one URL unless you apply some trick.
If your output structure is ready as shown your sample. Follow the below steps:
Right Click on TextBox>Placeholder properties
Select option HTML
Put the expression, similar as below:
I have tested with my sample data. Make changes according to your value.
Update:
From your comment, replace the field Fields!URL.Value to Fields!Title.Value (this is the field https://example/Title1).
To give you the undestanding, What the below code is doing?
"" & Fields!Title.Value & ""
It will generate the HTML links for title values from your source data.
Title1
Title2
Title3
& Chr(34) & - This is to tackle the special character ".
Adding the prefix in your join criteria will make sure it appears in each separation, and then add one at the beginning. Try to modify your join like this (free-coded).
="https://example/" & Join(LookupSet(Fields!Title.Value, Fields!Related_Project.Value, Fields!Title.Value, "TeamTasks"), Environment.NewLine() & Environment.NewLine() & "https://example/")
It is basically the same question I had in this thread:
Adding values to a Report when there is no Data in query SSRS
The only difference now is that I want to extend the same functionality to different Datasets.
Imagine this:
I have two Datasets. Dataset1, Dataset2.
Both have the same primary key, in this case:
Sales Rep
Category
Now in Dataset1 I have the following Data:
The idea in that thread was to put "0" Each time a Sales Representative Did not have all the categories, if you see for example Sales Rep on DataSet1, does not have G1,G2 Category so In those cases they have to put 0.
Thanks by the answer of the community this can be achieved by adding a Calculated Field on DataSet1:
=Fields!SalesRep.Value & "-" & Fields!Category.Value
So that will give you for example 11-G1 for the 1st Row. and the expression for each Row (For each category) will be:
=iif(IsNothing(lookup(Fields!SalesRep.Value & "-" & ReportItems!Textbox62.Value,
Fields!Another.Value,Fields!Sales.Value,"DataSet7")),0,
lookup(Fields!SalesRep.Value & "-" & ReportItems!Textbox62.Value,
Fields!Another.Value,Fields!Sales.Value,"DataSet7"))
As you can see, the ReportItems!Textbox62.Value saves the value of the Category so If 11-G1 is nothing (dont exist) put "0".
The idea here is to do the same thing with DataSet2.
The tricky part is that we have to ask if 11-G1 equals 14-G1 because in DataSet2 the SalesRep does not exist for all the categories it must put "0". Both are grouped as SalesRep.
Hello please can anyone assist
I have 2 datasets, one of them is filtered to bring back a set of numbers.
I have another dataset using the same data source which is filtered to bring back a different set of numbers.
I want to look up from one dataset to the other to have both sets of figures in the same matrix.
The Matrix is setup to have a name in a row, and month date in the colum.
I want to therefore look up the name from the 2nd dataset as well as the month number and return the value into the above.
Is there anyway to lookup against 2 conditions and return the value ?
Thanks !
Yes - you can combine the fields into one using a separator between the fields.
=Lookup(Fields!MonthNum.Value & "|" & Fields!aName.Value,
Fields!MonthNum.Value & "|" & Fields!aName.Value,
Fields!Number.Value, "Product")
The separator is used to keep values from the first field affecting values from the second.
Update:
For your issue when there is no month, you can try excluding them:
=IIF(ISNOTHING(Fields!MonthNum.Value), NOTHING,
Lookup(Fields!MonthNum.Value & "|" & Fields!aName.Value,
Fields!MonthNum.Value & "|" & Fields!aName.Value,
Fields!Number.Value, "Product") )
If MonthNum is NULL, it will return NULL (Nothing in SSRS).