How to prepare recursive reports based on a field value? - reporting-services

I am preparing a SSRS report where a table in the body has to be generated by considering a field value in header part and should repeat the same for all values of that field. I have created a group in body and used the expression =First(Fields!Field.Value, "DataSet"). It is generating all the values in the table but value in the header part doesn't change.
I also tried creating a group in the table and using one of the value from the group in the header part. But it is not possible as we are restricted to use group variables inside the group but not in the header part of the report.

Related

NOT LIKE FILTER on table in Report Builder

I have three tables on a report where I would like to filter the [NAMN] field so it only contains rows where the [NAMN] field contains "IKKE PROVISJON". Which values can I put in the Tablix Properties?
I can't choose = since the field could be "Smith - IKKE PROVISJON"
Tablix Properties
Set the expression to the field you want to filter by (NAMN in your case).
Set the Operator to Like
Set the Value to *IKKE PROVISJON* including the *
Check the following links for more information on filtering in reports and how to configure the expressions.
https://learn.microsoft.com/en-us/sql/reporting-services/report-design/add-a-filter-report-builder-and-ssrs?view=sql-server-ver15
https://learn.microsoft.com/en-us/sql/reporting-services/report-design/filter-equation-examples-report-builder-and-ssrs?view=sql-server-ver15

How do I combine data types in a SSRS Parameter?

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.

Dynamic groupings using IIF with multiple datasources

I'm using report viewer and trying to create dynamic groupings on my table. Before the report is generated, I have a popup that ask if the report generated should be grouped by category or not.
I have two datasets, one called ReportParameterDTO and the second is called LoanDTO
The tablix is connected to the dataset LoanDTO. I want to create a parent grouping expression for that tablix such that if the first value of ReportParameterDTO.GroupByCategory is true, then it should group, otherwise do nothing.
What I tried
=IIF(First(Fields!GroupByCategory.Value, "ReportParameterDTO") = true, Fields!Category.Value, ""))
It gives me back and error around Fields!GroupByCategory.Value and the error within the error list states that A group expression for tablix includes an aggregate function.
The IIF Expression will compile if I use Field Values from LoanDTO but I don't want to do that.
Add a new parameter.
Set it to Internal.
Set the Available Values to pull from the ReportParameterDTO dataset and the Value field will be GroupByCategory.
Also set the Default Values to pull from the ReportParameterDTO query.
Now you can refer to this internal parameter in your grouping expression like so:
=IIf(Parameters!GroupByCategory.Value = True, Fields!Category.Value, Nothing)
You can create both table and whit your parameter show or hide the table visibility. So like this I think is going to be more easy for you to set up your table and groups.

SSRS expression issue using iif function

I have a data set that is returning two properties, a name and a total units. I am trying to set an iif expression on a data bar where iif(field!Name.Value = "Name", field!Total.Value, 0)
this is not working I get an error of rsFieldReferanceAmbiguous, the fields refers without specifying a dataset aggregate. And the only option that it gives me as an aggregation is First, but I do not want to get the first name, I want the bar to display the total units base on the name field that is in the iif expression.
rsFieldReferenceAmbiguous refers to trying to match something that is not in local scope. Therefore you have to aggregate it. You are probably wanting something like this:
=Sum(IIF(Fields!Name.Value = "Name", Fields!Total.Value, 0))
The function you are trying to use would be better suited to a calculated field in your dataset. Then you can just refer that that field in your report. This allows you to filter the data line by line instead of by groups.
Right-click on the dataset and go to Dataset Properties.
Go to Fields.
Click Add then Calculated Fields.
Enter the name of the field and then the expression here.
Make sure your tablix has the dataset specified under General -> DataSetName on the properties pane. If you have more than one data set on the report you will need to specify which data set your reffering to like so:
(Fields!Name.Value, "NameDataSet")
If your useing tables you may need to ckeck if you have grouping and if so how your grouping your data.

Need help on SQL Server report

I have a question on SQL Server Reporting Services. In fact, I want to know about how to make a particular logic work.
I have a main report which has one sub-report inside it. The report takes an input parameter test_id and accordingly displays the data in tabular form.
When the test_id has a valid value that's matching, it displays the data.
But, when test_id doesn't have a valid value and hence it doesn't match, I get the empty table as below.
TESTNAME TESTDETAIL
Sub-report
TESTPARENTID PARENT DETAILS
I want to know how to display a message "No details found for the test_id" INSTEAD of displaying any empty tables. Only title and subtitle should display.
Objects like Tablix in SSRS have a property NoRowsMessage.
You can set this to display a message if there are zero rows.
Another option is to go into the tablix properties. Under Visibility, select Show or hide based on an expression. You can write an expression here to hide the entire tablix. Just change the name of the field to match yours:
=iif(Count(Field1)=0,True,False)