I have an RDLC report with a Pie Chart that has a category grouping and I'm trying to obtain the index of the current slice because I want to use it in the expression that computes the slice's color.
However, I can't seem to make it work. I've tried the following expressions:
=RowNumber(Nothing)
or
=RowNumber("Category_Group_Name")
or
=RowNumber("Chart_Name")
or
=RowNumber("Dataset_Name")
but none of these return the correct values, there are always duplicate values and/or skipped values.
What I'm looking for is the index of the slice (which is the same as the index of the legend entry), how do I correctly do that?
For clarity, the following screen shows how the chart is configured:
After some more trial and error, I've found the correct way. The correct expression to use is:
=RunningValue(CountDistinct(Fields!YourGroupingField.Value, "CategoryGroupName"), Sum, "ChartName")
Basically, this keeps a running count of the distinct count of the grouping property within the grouping (which is always 1
), so it will effectively keep track of the group index, which is the index of the slice of the pie.