SSRS矩阵中的交替行颜色表达式无法正常工作

Col*_*ind 1 sql reporting-services ssrs-2008 ssrs-2008-r2

在唯一的行组中,我尝试使用以下表达式获取备用行颜色:

背景颜色的表达式: =IIf( RunningValue (Fields!SP.Value, CountDistinct, Nothing) MOD 2, "White", "blue")

SQL code: 

select
ROW_NUMBER() OVER (ORDER BY DataDate) AS SSRSRowNumber
,datepart(dw,datadate) SSRSDateFilter 
,DataDate
,SP
,sum(TMI) as TotalCI
from table
where DataDate>GETDATE()-20
group by DataDate,SP
order by 1, 2
Run Code Online (Sandbox Code Playgroud)

结果是下面的图片,上面列出的表达式有什么问题?

问题的例子

编辑-解决方案

Han*_*ist 6

数据中缺少日期会导致背景行颜色无法正常工作。

您可能会浪费大量时间尝试使查询正常工作。

或者,您可以只使用交替行颜色功能。

Private bOddRow As Boolean
'*************************************************************************
' -- Display green-bar type color banding in detail rows
' -- Call from BackGroundColor property of all detail row textboxes
' -- Set Toggle True for first item, False for others.
'*************************************************************************
Function AlternateColor(ByVal OddColor As String, _
         ByVal EvenColor As String, ByVal Toggle As Boolean) As String
    If Toggle Then bOddRow = Not bOddRow
    If bOddRow Then
        Return OddColor
    Else
        Return EvenColor
    End If
End Function
Run Code Online (Sandbox Code Playgroud)

对于控制颜色的第一列:

=Code.AlternateColor("AliceBlue", "White", True)
Run Code Online (Sandbox Code Playgroud)

对于其余的列,请勿使用第三个参数切换:

=Code.AlternateColor("AliceBlue", "White", False)
Run Code Online (Sandbox Code Playgroud)

您可能需要切换矩阵第一栏中的颜色。

当某些行不可见时,SSRS交替显示行颜色问题