SSRS Expressions: Scope and Commenting Tips
In SSRS, Scope is confusing as hell. Below is an example of adding comments to SSRS expressions and how to probe scope. Adding a line like:
iif(inscope(“matrix1_dept”),”[d]“,”")
will display a “[d]” in cells that are in the scope of group “matrix_dept”, and nothing if it is outside that
scope. By adding multiple scope tests, you can see where cells lie in the scheme of things.
Here is my full example:
=iif(inscope(“matrix1_teacherDisplay”),iif(inscope(“matrix1_courseName”),IIF(ISNOTHING(Fields!personID.Value), “”, IIF(Fields!personID.Value=0, “”,ROUND((COUNT(Fields!personID.Value)/Fields!classCount.Value)*100) & “%”)),IIF(ISNOTHING(Fields!personID.Value), “”, IIF(Fields!personID.Value=0, “”,ROUND((COUNT(Fields!personID.Value)/Fields!courseCount.Value)*100) & “%”))),IIF(ISNOTHING(Fields!personID.Value), “”, IIF(Fields!personID.Value=0, “”,ROUND((COUNT(Fields!personID.Value)/Fields!deptCount.Value)*100) & “%”)))& IIF(0,” <— this entire line begins my comment —>The lines above and below this sentence cause SSRS to ignore the lines inbetween. The “IIF 0″ constraint guarantees that the IIF statement evaluates false, therefore this text will never be displayed. Below this are are my debugging lines to probe the scope of my matrix report. They will display the code letter for each level of scope they are contained by.<— this entire line finishes my comment —>”,”")& iif(inscope(“matrix1_dept”),”[d]“,”")& iif(inscope(“matrix1_courseName”),”[c]“,”")& iif(inscope(“matrix1_teacherDisplay”),”[t]“,”")& iif(inscope(“matrix1_periodName”),”[p]“,”")
Here is what my rendered report looks like with the probes in place:
1 Comment »
RSS feed for comments on this post. TrackBack URL

[...] Read Full Article Uncategorized Implementing Data Bars In A Grouped Table » [...]