Archive for August, 2012

Reporting Services – Conditional line break

I had a requirement to add a “line break” (i.e. an empty row) between group types. Below is how I wanted to format my results. The numbers 8:00 and 9:00 belong to a field called Time. The second field (11-AA, for example) is called FunId, which isn’t used in the code, and the third column (Circus) is called FunType:  

Line break

Line break

8:00
 11-AA Circus
 12-BB Circus

10-BB Fair

9:00
 11-AA Circus
 12-BB Circus

 11-CC Theme Park
 11-DD Theme Park
 

Notice that the line break never appears right after the row that displays the time, only when the group is different than the one preceding it.

I set Row Visibility property of the new row to this:

=IsNothing(Fields!Time.Value) Or (Previous(Fields!Time.Value) <> Fields!Time.Value) Or (Fields!FunType.Value = Previous(Fields!FunType.Value))

When Time is the row just above the row being evaluated, a line break never happens. (Wouldn’t be prudent at this juncture, as Dana Carvey imitating George H. W. Bush would say.) Only if value in FunType doesn’t match the one right above it will the line break row be visible and give us the awe-inspiring results I want.

P.S. No confidential information was harmed or revealed in the making of this article. After all, I don’t work in an industry that has anything to do with circuses, fairs, or theme parks. Unfortunately, because that would be pretty sweet if I did.

Leave a comment