reporting-servicespowerbissrs-tablixreportbuilderpowerbi-paginated-reports

SSRS number of occurences for runningvalue


I'm trying to create the ABC / Pareto Analysis. Intention is to mark by 'A' all products which generate 80% of total sales, 'B' products which generate additional 15% and 'C' the rest. It's up to 100k products which have to be taken into account and fastest way to calculate running total is by using the RunningValue in the Report Builder / Paginated Reports.

I did some testing by calculating running total while downloading data to the dataset but it's very slow and therefore not an option. RunningValue on the other hand works perfectly fine and I can mark the products by 'A', 'B', and 'C' in the Tablix. This is the formula:

=IIF(RunningValue(Fields!ACT.Value, Sum, Nothing ) / Sum(Fields!ACT.Value, "Facts")<0.8, "A", IIF(RunningValue(Fields!ACT.Value, Sum, Nothing ) / Sum(Fields!ACT.Value, "Facts")<0.95,"B","C"))

However, I can't find a way how to count the number of products with A, B and C. Idea is to show that X% of products create 80% of total sales, Y% additional 15% and Z% generate only 5% of turnover.

I'd be thankful for any advice, I'm running out of options. Original datasource is Power BI dataset and calculating running total while downloading the data is really slow for this number of products. Tested with MDX and DAX.


Solution

  • You can use custom code for your pareto count calculation.

    Add the following code to your report

    Public Dim a_count, b_count, c_count As Integer
    
    
    Public Function Pareto( current As Integer, total As Integer) As String
    
    If current / total < 0.8 Then
    a_count = a_count + 1
    Return "A"
    ElseIf current / total < 0.95 Then
    b_count = b_count + 1
    Return "B"
    Else
    c_count = c_count + 1
    Return "C"
    End If
    
    
    End Function
    

    For your parent classification column use the expression

    = Code.Pareto( RunningValue(Fields!ACT.Value, Sum, Nothing ) , Sum(Fields!ACT.Value, "Facts"))
    

    To display the counter variables use the expressions

    = Code.a_count
    = Code.b_count
    = Code.c_count
    

    enter image description here

    enter image description here