Reputation: 7092
I have following situation:
Report with nested groups, whether group column has value 1 or 2. Next child group has 2 groups for each parent group, so for parent group 1 there is two child groups (1-1 and 1-3), and also for parent group 2 I have two child groups (2-2 and 2-4).
My question is, how to set color to WhiteSmoke
for rows from 1-1, and color White
for rows from 1-3, and again WhiteSmoke
for 2-2 and White
for 2-4.
If there is order like 1, 2, 3, ..., then will be easy with using Mod
operator, but my order is 1, 3, 2, 4 and i cannot find algorithm for alternating color
EDITED
Upvotes: 2
Views: 24555
Reputation: 5839
=IIF(RunningValue(Fields!FieldToGroupOn.Value, CountDistinct, "ParentGroupName") Mod 2, "LightGrey", "Transparent")
Where:
FieldToGroupOn
is the field in the dataset you are grouping on and wish to produce alternating colors.
ParentGroupName
is the name of the row group in the tablix that is the parent of the group you wish to alternate colors for.
Upvotes: 3
Reputation: 41
I found the answer.
=IIF(RunningValue("NameofGrouptoAlternateColor", CountDistinct, "NameofParentGroup") Mod 2, "White", "Wheat")
This worked for me and I think it's what the original poster was trying to accomplish.
Upvotes: 4
Reputation: 1539
I've forced to use custom code to achieve your goal, here is my solution:
Custom code section
Public Shared ReverseLookup = True
Public Function GetColor(ByVal currentValue As Integer, ByVal previosValue As Integer) As String
If ReverseLookup = True
If currentValue = previosValue Then
GetColor = "Gray"
Else
GetColor = "Green"
ReverseLookup = False
End If
Else
If currentValue = previosValue Then
GetColor = "Green"
Else
GetColor = "Gray"
ReverseLookup = True
End If
End If
End Function
And in the BackgroundColor property :
=Code.GetColor(Fields!secondid.Value, Previous(Fields!secondid.Value))
input parameters are current secondid value (value from paren group of details) and previos secondid value.
And here my result: I believe that it is exactly what you need :)
Upvotes: 1
Reputation: 5114
If I understood correctly you want to alternate colors on "group change". If so, this is the solution:
IIf(RowNumber("TheNameOfYourGroup") Mod 2 = 0, "White", "WhiteSmoke")
That's the expression you use for your Background Color
property.
Upvotes: 1
Reputation: 2429
assuming that this is the order: 1,3,2,4,5,7,6,8...
you want to color only 3,4,7,8..
Then the expression should be:
=iif(RowNumber(Nothing) Mod 4 <> 0 AND
((RowNumber(Nothing)+1) Mod 4 <> 0), "White", "WhiteSmoke")
Upvotes: 1