SSRS foreach loop based on the ids of a query

Viewed 106

I'm very new with SSRS and currently struggling with what I want to achieve.
Imagine having a query that returns these data:

UserId From To Value Name
1 2021-10-1 2021-10-31 10 Name1
1 2021-11-1 2021-11-30 20 Name1
2 2021-10-1 2021-10-31 100 Name2
2 2021-11-1 2021-11-30 200 Name2
... ... ... ... ...

In my SSRS report I king of want a foreach-Loop so that every user gets his own section based on the UserId like:

Name: Name1

From To Value
2021-10-1 2021-10-31 10
2021-11-1 2021-11-30 20

Name: Name2

From To Value
2021-10-1 2021-10-31 100
2021-11-1 2021-11-30 200

...

How is this possible to achieve?

Thanks in advance

3 Answers

Add a row group with a group header that groups by UserID.

enter image description here

In the rowgroup header you can put the Users name and ID etc.

While adding a grouping to the same table may solve your issue, you may want a table or multiple objects to repeat for individual groups.

In this case, you may want to use a LIST object to group your data and then put your table (and any other objects you may want), inside a single (large) cell of the LIST.

There is a table of Regions, but it needs repeat it for a higher group - COUNTRY.

enter image description here

Add a LIST and group by the COUNTRY field. Make the single cell the same size as the other table. Put the Region table inside the single cell of the COUNTRY List. For you scenario, you would use the UserID.

enter image description here

The list repeats for each Country. For you table, it would repeat for each user.

A row (inside group) can be added so a separate header can be created for each User so you can add their ID, name and whatever else is needed on the report.

Assuming you mean that you want to seperate out each set of rows by the value in the UserId field, you just need to add a table to your report that has a group based on the UserId field.

If you do that, the table will group together all the rows for each unique UserId and also allow you to add subtotals etc

Related