Search code examples
sqlreporting-servicesreportindentationiif

SSRS - How to indent row based on a condition?


In SSRS, I have a report for example:

Designation                Type          Amount

Admin1                     Gift           50
Admin1                     Payment        50
Admin1                     Payment        50
Admin2                     Gift           100       

So basically Admin1 can receive a gift of $50 for example, and any additional payments made toward this same designation will be classified as a payment from then on, and I'd like to left indent the corresponding payments relating to the initial gift to look like so:

Designation                Type          Amount

Admin1                     Gift           50
     Admin1                Payment        50
     Admin1                Payment        50
Admin2                     Gift           100

My logic would be something like if the Designation is the same, and the Designation has a Type of Payment, then these have to be indented underneath the same Designation where the Type is Gift.

I've never worked with indentations before in SSRS, Is this possible to do?


Solution

  • You will need to add a row group to your report that groups by Designation. If you currently only have a 'details' row group then right-click it and add a parent group. You can delete the new column if one is generated,, but do not delete the group.

    Let's assume when you create this row group that you called it grpDes

    Next, in the textbox you need to adjust, click it and in the properties panel, find "padding" and expand it out, click the drop down in "left" and choose "expression".

    enter image description here

    Set the expression to something like

    =IIF(ROWNUMBER("grpDes") >1 AND Fields!Type.Value = "Payment", "10pt", "2pt")
    

    Adjust the 10pt to whatever you want...

    Note that the group name must be enclosed in quotes and is case sensitive.

    So what this does is, groups the data by designation, then checks the row number within each group. If the row is not the first group with in the group AND the type is "payment" then set the padding to 10 point otherwise set it to 2pt (SSRS default)