Search code examples
sql-serverreporting-servicesgroupingssrs-tablix

SSRS count of rows within each group


I have a report that will show several groups of details records on the page. I would like to order them so that the groups with more rows are first. Does anyone know what formula should show me the details row count per group? I tried =CountRows(MainGroup) but that errored.

design view

output with row count


Solution

  • If you include a scope name in any expression, it has to be enclosed in quotes and is case sensitive, so in your case it's just a case of adding the quotes...

    =CountRows("MainGroup")
    

    Note: If the expression sits in the "MainGroup" row(s) anyway, then there is no need to specify the scope so =CountRows() would return the same results as when no scope is specified, the current scope is used.