问题
I’ve got a Matrix with multiple page splits for each product group. I’m using the below expression to get alternating row color for each product group. The problem is that it works as expected only on page 1. Other pages (i.e page 2) bring back undesired results as per the below screenshot:
Expression:
=iif(RunningValue(Fields!CurrentIntroducerManager.Value.ToString,CountDistinct,Nothing) Mod 2,"Gainsboro", "White")
回答1:
I've had issues with using Running Value occasionally and just use the Alternating Row Color function that someone created a while back.
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
For the first column that controls the color:
=Code.AlternateColor("AliceBlue", "White", True)
For the remaining columns, don't toggle with the third argument:
=Code.AlternateColor("AliceBlue", "White", False)
You may need to switch the colors in the first column in a matrix.
Alternating row color expression in SSRS matrix not working correctly
SSRS Alternating Row Colors Within Groups
回答2:
Aggregate functions like RunningValue
have an optional argument to override the scope. In your case, you'll need to reference the correct Row Group within which you are trying to count rows. As opposed to the lowest level of detail which is what it's doing by default. It should look like this, but with your group name:
=iif(RunningValue(Fields!CurrentIntroducerManager.Value.ToString,CountDistinct, "MyGroupNameHere") Mod 2,"Gainsboro", "White")
来源:https://stackoverflow.com/questions/54825950/add-alternating-row-color-to-ssrs-matrix-report-with-page-splits