So, I've posted a question few days ago here where I had a #Sem_ID parameter and I had to pass multiple IDs separated by a delimiter. I found solution but it only works when I have one dataset. The problem now is that my report has 3 tablixes and 3 datasets, one dataset for each tablix.
What I tried: I created a a tablix and inserted a rectangle element inside row. I moved a grid inside the rectangle and then tried running the report but received an SSRS error while previewing: The Value expression for the text box ‘Textbox10’ refers to the field ‘Kondition’. 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.
For example, each of these two queries represent a dataset, so two datasets:
SELECT Sem_ID, Sem_KW, Sem_Jahr, Sem_SemNrKata, Sem_von, Sem_bis, h.chr_name, h.chr_ort
FROM acc_seminar.t_Seminar
JOIN dbo.tbl_hotel h ON Sem_Ht_ID=h.pk_hotel
WHERE Sem_ID IN (SELECT value
FROM fn_Split(#Sem_ID, ';')
WHERE RTRIM(value) <> '') AND (Sem_SemTh_ID != 76 AND Sem_Sto = 0)
and second dataset:
SELECT tu.TU_Name AS Name, tu.TU_Vorname AS Vorname, ParkgebuehrBrutto AS Preis
FROM acc_seminar.t_Teiluber_Ext tux
JOIN acc_seminar.t_Teiluber tu ON tux.TeiluberId = tu.TU_ID
JOIN acc_seminar.t_Seminar s ON tu.TU_Sem_ID = s.Sem_ID WHERE s.Sem_ID IN (SELECT value
FROM fn_Split(#Sem_ID, ';')
WHERE RTRIM(value) <> '') AND ParkgebuehrBrutto IS NOT NULL
So if I pass a #Sem_Id = 123;456 , how do I then show two grids for Id=123 and then for Id=456 ?
Few Observations: You cannot move another Tablix for Dataset1 to Tablix (Rectangle) Dataset2. They are different. You could use SubReport wherein Inside Tablix 1 you have SubReport which uses Dataset2 and shows it's data.
Second:
Your Use Case can be very well solved with Sub-reports. How??
Pass your Sem_ID as parameter to SubReport provided your Dataset2 (subreport) does conatin Sem_Id field.
Few Links for help
http://t-xie.net/2016/05/17/ssrs-pass-multiple-value-parameter-to-sub-report/
https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/dd220581(v=sql.105)
Related
I have a report having two tab-lix and also two data set(e.g=dataset1,dataset2) for each tab-lix. When i am generating report by passing the multiple parameter location id(38,39 & 40) value if there is no record of id-38 in dataset2 i want blank space but in my report it is showing report of 39. But i want if there is no data in data set based on the parameter it is showing only blank space.Because always dataset1 having data and so it showing properly.When i am generating report with multiple parameter(38,39,40) it showing tablix1 of 38 parameter but tablix2 of 39 parameter in on page because of there is no data in dataset2 of 38 parameter.So i want to display a blank space on behalf of tablix2 if there is no data.
Give me a solution.
This answer assumes you have a table that contains all locations e.g. DimLocations, if not you should consider creating one.
You can then change your dataset query to be something like.
SELECT loc.LocationID, t.SomeColumn, t.AnotherColumn
FROM DimLocations loc
LEFT JOIN myTable t ON loc.LocationID = t.LocationID
WHERE loc.LocationID IN(#myLocationParameter)
This will ensure that you get a record for each location as long as it appears in the DimLocations table.
If this does not help, edit your question to show the dataset query you are using now and the structure of your locations table (if you have one)
Background -- I’m trying to create a report in SSRS using Report Builder 3.0 that contains multiple parameters. The request is when the report is opened, display all rows of data. The end user can then select one or more of the parameters to reduce the results displayed. I can get it to work using something like the following.
Data sets for Parameters where available values are from a query,(dataset type is text)
For fields that are numbers:
SELECT 0 'FACG' UNION ALL SELECT DISTINCT STR(ACG) FROM STG_CSI_SA_CONFIRM
For columns containing text:
SELECT 'Any' 'FunderName' Union All Select DISTINCT NAME FROM STG_CSI_SA_CONFIRM
In the dataset for the report I have this:
WHERE ('Any' IN (#FrName) or Fname.name in (#FrName)) AND ( 'Any' IN (#FACG) OR FLIST.FACG IN (#FACG))
The results are two Parameter boxes, one says 0, one says Any, and the report runs when first opened. End user can then select one or more numbers from FACG or one or more names from FRName.
My question is, how can I adjust the first parameter to show ‘Any’ instead of a zero as the default value? All the values returned would be integers of 7 digits long. When I simply change the 0 to Any I get an error message about converting data types. If I use STR() I can get a list out of SQL server I get a list as I expect. ( Any, 1234567, 1234568 etc.) But I cant get the list to work in SSRS.
Thanks
R
Two way to do this.
1. Make sure the dataset that provides values for your parameters has two columns, an ID column that you will use to actually do the filtering/joins in your dataset and the other column is the label which will be visible to the user. Something like
ID Label
'Any' 0
'1234567' 1234567
'1234568' 1234568
If you main data dataset is a query (not a Stored proc) then you can simply have a parameter dataset as above but without the 'Any' row. Then set you available value to the parameter dataset and the default values to the same parameter dataset. By default all parameters will then be selected.
In your main data dataset the query would be along the lines of
SELECT * FROM myTable WHERE myColumn IN (#myParameterName)
SSRS will turn the selected values from the parameter into a list of comma separated values and inject them into the query for you.
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
I have the following switch statement within an SSRS report, but it errors out when I run the report.
Basically Parameter 1 is a multi value parameter, and when the parameter has two values selected where they are two distinct values, I want a certain text to appear.
=SWITCH(Parameters!Parameter1.Count = 2 AND Parameters!Parameter1.Value(0) = "TEXT1-NY" AND Parameters!Parameter1.Value(1) = "TEXT2-LA" , "Combined (NY & LA)"
, True, JOIN(Parameters!Parameter1.Label,"& ")
)
Additionally, regardless of the numbers that are selected (i.e if there were 6 parameters that were selected), is it possible that these two parameters would be replaced with that particular text followed by , and then names of other parameter values?
First of all, good job working out the expression that you have. You're on the right track, but expressions don't have a programmatic way to loop through the values of the parameter.
One option to do specifically what you asked would be to add a custom function to the Code section of your report that could loop through the parameter values.
Another option would be to simply UNION this "Combined (NY & LA)" value to your dataset so that it is available as one of the options.
In SSRS 2008 R2, is it possible to have a parameter that looks for specific data inside a cell?
For example:
I have expression (Fields!input_criteria.Value) which contains multiple values separated by ;#
;#Action01;#Action02;#Action03;#Action04;#Action05;#
Depending on the row the cell can be populated with different combinations
Row 1 = ;#Action01;#Action04;#Action05;#
Row 5 = ;#Action01;#Action05;#
Row 7 = ;#Action03;#
...
I want to create a Parameter to filter the dataset by looking into Fields!input_criteria.Value and display the rows with the value selected
Available Values:
Action01
Action02
Action03
Action04
Action05
If I select Action01 from the Parameter drop down the report displays only Rows 1 and 5. If Action04 is selected only Row 1 is displayed.
Thanks in advance for the help!
You can set the filter on your dataset
1) Write custom code that will accept two parameters one is your parameter selected value separated by comma. You can join your values using
=Join(Parameters!input_criteria.Value.Value, ",")
second is your input_criteria field value
2) The method will split the parameter value and loop through the each value and and then using InStr it will determine if the calue is present in input_criteria field. If present then it will return true.
3) In filter set the expression as
= Code.Yourfunction(Join(Parameters!input_criteria.Value.Value, ","),Fields!input_criteria.Value)
4) In filter Set the operator to =
5) In filter Set the value to the True
That will filter all your records which contains your selected parameter values.
You can add the custom code in Report by going into menu bar options,
Report->Report Properties -> Code
You can just use Instr() function in your filter.
=InStr(Fields!input_criteria.Value,Parameter!param1.Value)
>
0