SSRS - Get current tablix iteration index - reporting-services

I have a report which contains a tablix. Within this tablix I have a subreport that is called at each tablix iteration.
I would like to obtain the current index of the tablix iteration inside the subreport. I have passed a subreport parameter using below expression:
=RowNumber("dataset")
dataset is the one assigned to the tablix in the report. In my concret case, this expression is not working.
Any other way to get this work?

Is your tablix grouping the data from your dataset? If so, can you do that grouping/aggregation in your SQL and return only the final dataset in the format the tablix will be displaying it?
If you can manage that, you can simply add a ROW_NUMBER() OVER (ORDER BY <column names>) as RowNum and pass that through as =Fields!RowNum.Value to your subreport.

Related

How to populate an rdl table based on data returned from a query?

I have absolutely no experience working with rdl files and I received a ticket from a client asking us to display multiple reports in one report. What I have done so far is created a master rdl file that contains a sub-report. That subreport is linked to another rdl file which is the actual report that is normally generated. What I want to do is generate a list of those subreports based on the data received in an array from a query. So if there are 6 elements in the array then I need to have 6 subreports generated, with each report using data from the appropriate index in the array.
I managed to figure out how to connect the data for one subreport but I have no idea how to scale that programatically.
The basic steps are
Create a subreport that accepts parameters (done I guess)
Create a master report (done)
Create a dataset in your master report that contains a row of data for each subreport. For example. If you subreport showed employee details for a single employee, your main report might contain a dataset that lists employee IDs for a department.
Add a tablix to your main report, remove header row and leave only a single column. Stretch this column to fit your report width
Set the datasetname property of the tablix to the name of your dataset, (now it will produce one row per employee)
Right click the tablix cell and insert subreport
Right click the subreport placeholder -> properties then choose your subreport form the drop down.
Set the subreport parameter(s) to be the values from your dataset (e.g. EmployeeID = empID)
That's it.
You main report will run, the tablix will create a row per record in your dataset, this in turn will give you a subreport per row in your dataset, each of those subreports will have the value of the field from that row passed to it.
If you need more help, I'll try to track down a similar answer I posted a while back which had more detail.

SSRS Report - using the value from the subreport in a calculation in my main report

I am writing an SSRS report using report builder and have my main report and a sub report - I have had to do this because one of the figures is in a different table. The main report shows a customer column an amount column then my subreport column - in the next column I need to show these two figures added together, there is then a further column with another figure in and the final column will deduct the fourth from the calculated third - I dont know how to write an expression which incorporates the subreport value.
You can't retrieve values from a subreport like you wish as that's not how subreports work.
When you run the SSRS report, the parent report passes parameters to the sub-report (the only data transfer between the two), the subreport is rendered and then the rendered subreport is inserted back into the parent report as the parent report is rendered.
As I see it, you have two options to tackle the problem.
1) Join the data from the two tables in your source query so that all the appropriate information is within one dataset in your report.
2) Use the Lookup function to retrieve values from the second dataset. This is a very flexible option and one that I highly recommend that you review for scenarios like this.

Filtering an ssrs report on a column created with a lookup function

I have created a transaction report in ssrs reporting data from dataset1 where one of the reported columns is populated using lookup function to get data from another dataset (dataset2). If no data is found in dataset2, the lookup function returns blank, which is what I want. I have now been asked to filter the report so that only includes those transactions which are not included in dataset2.
I have looked for a way and tried using the lookup function in the tablix filter expression, but have read that the lookup function is done after all filtering which would indicate that this may be one of those requests that will not be fulfilled. Have any of you tried this?
Add a filter like this in your tablix in tablix properties / Filters tab:
For Expression use:
=ISNOTHING(
Lookup(Fields!FieldDS1.Value,Fields!FieldDS2.Value,Fields!FieldDS2.Value,"DataSet2")
)
In Value use:
=True

SSRS Report issue while adding column in tablix group setting

I am having issues with an SSRS Report. I need to modify the SSRS report that has nested tablix grouping. I need to add a single column in that group, but I want to take the sum of values in that column and exclude grouping settings. Is there any way to do that?

SSRS IIF Syntax with Multiple Datasets

I have a report with 2 data sets and would like to perform a SUM operation in a textbox expression. The problem arises when I want to perform an IIF in the sum since I only want a particular category of values summed.
I would like to get a sum of all the "Good" ranking values from the dsRetrieveCustomerAssetScores dataset. Please note there is more than one data set in the report, so I need to specify the scope when using the aggregate function. Below is the code I've tried (along with other permutations).
=Sum(iif(Fields!ranking.Value,"Good",1,0), "dsRetrieveCustomerAssetScores")
Any ideas?
You may have more than one dataset in your report, but I don't think it's possible to have more than one dataset per tablix. (Subreports within the tablix may be bound to a different dataset, but anywhere within the subreport will only be accessing that other dataset.)
The scope specified within aggregation formulas is normally related to groups within the tablix, not the datasources.
So, the code:
=Sum(iif(Fields!ranking.Value,"Good",1,0))
- should work within your tablix, as long as that tablix is accessing the dsRetrieveCustomerAssetScores dataset.