SSRS lookupset - row output - reporting-services

I am looking to use the lookupset function. I have a one to many relationship when one Risk has many Actions.
Using this function I can return it as a comma separated line, however what I really need is for each entry to display in a new row of a table, is this possible?
I have replaced the comma so instead of creating a comma separated line it does a newline, however I need it to line up with other values. This Is why I would like to to come out in rows in a table.

Can it display on separate lines rather than separate rows? If so, then you can simply separate the fields using carriage return/line feed pairs, like so:
=Join(LookupSet(Fields!Id.Value, Fields!Id.Value, Fields!FieldToLookup.Value, "LookupDataset"), vbCrLf)
Otherwise you are better off defining a subreport and embedding that in your table. The subreport is simply a report that is just a table with the report taking a parameter. You add this to the table in the main report using the toolbar and then set the parameters in the subreport properties to pass in the identification field name from the table's dataset.

Related

Microsoft Report Builder: How to display selected chosen values from a multi-value parameter in a table?

I'm using MS Report Builder v3.0 to create a report. As part of this report, I have a multi-valued parameter (named #Diagnoses). The labels and some of the values (truncated by the size of the display boxes) of this parameter are shown below:
What I would like to be able to do is display the labels / values the user chooses in a 2-column tablix (I've tried using separate textboxes for the labels / values but the results are mis-aligned).
However, this does not appear to be straightforward. The closest method I've found is this one, which stores the user's choices in an internal parameter in xml format, then queries this parameter to produce a dataset from the xml.
So, I created the xml-producing internal parameter like this:
...and I've created a dataset based on this data, with the following query:
But now when I put these values into a tablix, the labels and values are now on separate rows, like this:
Does anyone have a straightforward way of sorting this out?
Best Wishes
C J
OK - I've solved it (it's not pretty, but it works!)
Basically, the problem comes from having to use the join statement when creating the xml - you can't really put both the label information and the value information on the same row in the xml.
To get round this, you have to use two internal parameters to create two datasets - one for the labels column, one for the values column. The method for creating these is essentially the same as that shown above, except for the values parameter, the expression for the default value is:
...and for the labels parameter, it's this:
(by the way, make sure you set the available values to "None" for internal / hidden parameters - the expressions here are for the default values)
Then, when you create the values dataset, you use the following syntax in its query:
...and similarly for the labels dataset.
Finally, in the report, you create one matrix from each of the two datasets, then put them next to each other, using fixed row heights and setting "can shrink" / "can grow" to false so that they look like they're in the same table:
I hope this helps somebody!

In SSRS, how to include first row from different dataset in tablix?

I am creating a report, the purpose of which is to print a letter to many different people. Obviously each person's name, email, etc. will be different. For this I am using a list, which I understand uses a tablix.
Now inside each letter I also need some global data that comes from a dataset. For example, the company email, telephone number, etc. This data will be the same for every letter. However, every time I try to use some expression to get this, I get an error such as:
The Value expression for the text box ‘Textbox11’ refers to the
field ‘URL’. Report item expressions can only refer to fields within
the current dataset scope or, if inside an aggregate, the specified
dataset scope. Letters in the names of fields must use the correct
case.
The expression I'm using to get the above error is
=LookupSet(true, true, Fields!URL, "SystemVars")
I've tried other things but I can't figure out what I need to make it word.
Is there an expression I can use to solve this problem? If not, what steps should I take to get my letters working?
You are missing the ".Value" portion in the expression. Try this:
=First(Fields!URL.Value, "SystemVars")

SSRS report with muliple datasets

I have added a separate dataset to an SSRS report...it contains some similar tables as another dataset. When I go to write expressions the fields in my new dataset have a "SUM" in front of the field numeric fields and "First" in front of the char fields??? Now I can't pick the numeric field for my report because it will "SUM" up all the data
Just remove the SUM() portion once you add the field. Perhaps it is there because of the scope of the bound item. There is no harm in removing the aggregate if the field is in a position in which a detail can print SUM(X)=X.
To follow on the heels of Ross' answer...
You can remove those [SUM(FIELD)] tags from your table by clicking it and hitting delete. To add the single data value you want to display, type the field name in brackets like [FIELD] right into that text box.
Alternately, edit the expression the be:
=Fields!YOURFIELDNAME.Value

How to populate a Tablix referencing data from another Tablix dataset?

I have two Tablix: Tablix A and Tablix B:
Each Tablix is connected to different datasets as illustrated in the image below:
How do I populate Tablix B by looking up data in Tablix A?
For example: Tablix A contains Vehicle models but I also need to populate Tablix B with Vehicle colors using the VehicleID in both dataset.
Using a Lookup Function, this only works if both datasets are references in the same tablix, how do I do this using separate tablix?
Attempting to use separate tablix, I get the below error:
[rsFieldReference] The Value expression for the text box
‘Textbox57’ refers to the field ‘VehicleColor’.
Report item expressions can only refer to fields within the current dataset scope or,
if inside an aggregate, the specified dataset scope.
Letters in the names of fields must use the correct case.
Illustration:
You can use "lookup" to get a single value from another dataset. For example:
=Lookup(Fields!VehicleID.Value, Fields!VehicleID.Value, Fields!VehicleColour.Value, "Vehicles")
would bring out a single (the first in the dataset) VehicleColour where the IDs matched. If there is only a single match of ID between the two datasets, then the correct colour would be returned.
=LookupSet(Fields!VehicleID.Value, Fields!VehicleID.Value, Fields!VehicleColour.Value, "Vehicles")
brings out an array, which can only be displayed in a textbox if it's converted into a string using join:
=join(LookupSet(Fields!VehicleID.Value, Fields!VehicleID.Value, Fields!VehicleColour.Value, "Vehicles"), ", ")
which will bring out a comma separated list of all VehicleColours where the IDs match.
For more information on Lookup, see: https://msdn.microsoft.com/en-GB/library/ee210531.aspx
For more information on Lookupset, see: https://msdn.microsoft.com/en-us/library/ee240819.aspx

Concatenate distinct row values for field in reporting services

I have a report in reporting services and I want to concatenate all the distinct values of a column separating by commas and place the value in a textbox. I know I could do it in the SQL using one of the answers here. But I'd rather not change the sql and just do it in the report if possible.
Example: I've got a dataset with several fields, one of which is category. Say the values are "Phone", "Service", "Phone", "Accessory", "Case", "Case". I want the textbox in my report to end up with the value "Accessory, Case, Phone".
In case it makes a difference, it is SSRS 2008 R2.
I've figured out a way, although not the most elegant solution. I've added an internal parameter to get the list of all possible categories as well as an additional parameter to get rid of the duplicates. I've followed the steps here (starting at the part where they are adding dummy parameters) to do the above.
Essentially,
Create a mulit-value parameter using the dataset and field I want for
available/selected values. Be sure to mark as internal on the
General tab.
Add the RemoveDuplicates function shown in the link to the Code tab
in Report Properties
Create a second multi-value parameter that uses the RemoveDuplicates
function. Similarly, be sure to mark as internal.
After that I used the Join function on the second parameter to create the comma delimited list.