Search code examples
reporting-servicesssrs-2012ssrs-tablixreporting-services-2012

SSRS - How to indent rows in a table with a given content


In SSRS I want to indent certain rows when they start with e.g. 'aa'. See this example:

See this example

What is the best practice in this case? As I don't have a parent-child situation here (to use recursive hierarchy group), do I have an option e.g. via the properties to set something like an IIf to solve this? If yes, could you please provide some information where to set this?

Every info is welcome! I'm new to SSRS.


Solution

  • This is simple to do...

    Click on the cell that you want to indent.

    In the properties panel, expand the Indent properties and then click the drop-down in the Left Indent property and choose Expression.

    Then set the expressions to something like

    =SWITCH (
        LEFT(Fields!FieldIwantToCheck.Value, 2) = "aa", "10pt",
        LEFT(Fields!FieldIwantToCheck.Value, 2) = "bb", "30pt",
        True, "0pt"
    )
    

    You could do this with an IIF expression but if you need to make it more flexible than 1 or two cases then SWITCH is much easier to read/manage.

    All we are doing here is checking the left 2 characteras of the FieldIwantToCheck field and setting an indent value respectivley. If none of the criteria match, the final True, Nothing acts like an ELSE and leaves the property as the default Nothing value.