SSRS conditional formatting column with alternating row highlighting and NULL handling

五迷三道 提交于 2019-12-24 21:33:26

问题


I have an SSRS report where I'm supposed to conditionally format a column red/green depending on if an expression is +/- 5% (less is good, so less is green). I also need to have the entire report have alternating row highlighting. I can get these to function correctly until I throw in some NULL handling.

=Switch
(
IsNothing(Sum(Fields!August2015.Value)),IIf(RowNumber(Nothing) Mod 2 = 0, "#d9d9d9", "Transparent"),
(Fields!August2015.Value-Fields!CorporateAvg.Value)/Fields!CorporateAvg.Value >= .05, "Pink", 
(Fields!August2015.Value-Fields!CorporateAvg.Value)/Fields!CorporateAvg.Value <= -.05, "LightGreen",
(Fields!August2015.Value-Fields!CorporateAvg.Value)/Fields!CorporateAvg.Value > -.05 And 
(Fields!August2015.Value-Fields!CorporateAvg.Value)/Fields!CorporateAvg.Value < .05, IIf(RowNumber(Nothing) Mod 2 = 0, "#d9d9d9", "Transparent")
)

It looks like the issue is that once something is green or red the alternating row highlighting resets and throws the rest of the rows off. Here's an example:

Example of issue


回答1:


I believe the issue is around the section

IIf(RowNumber(Nothing) Mod 2 = 0, "#d9d9d9", "Transparent")

As no scope has been set it is not clear when the row count is reset to zero. You cold always see what this rownumber value is by temporarily adding a second expression to the cell to show just the RowNumber(Nothing) value

Have you tried using CountDistinct and RunningValue instead (assuming you have a unique value per row). For example, replacing the noted section above with

IIf(RunningValue(CountDistinct(Fields!Serial.Value), Sum, "DataSet1") mod 2), "#d9d9d9", "Transparent")

This is then based on the dataset you are reading and the sort order of the results, and not just the order of the rows as they appear on the report itself.



来源:https://stackoverflow.com/questions/32502221/ssrs-conditional-formatting-column-with-alternating-row-highlighting-and-null-ha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!