Forum Discussion

mol_ad's avatar
mol_ad
Frequent Visitor
2 years ago

Cumulative Total

I am trying to create a Pareto Chart using Dax Formulas for the set of 5 metrics in a column (Error Column below)...I have created the following Dax Measures:

Error Volume = Data from the data source table
Running Total = 

VAR CurrentCount = [Error Volume]
RETURN
    CALCULATE([Error Volume],
    FILTER(
        ALL('Follow-Up Team'[Errors]),
        [Error Volume]>= CurrentCount
    ))
Chart % =
VAR ErrorCount = [Error Volume]
VAR AllErrors = CALCULATE([Error Volume],ALLSELECTED('Follow-Up Team'))
RETURN
DIVIDE(
SUMX(
    FILTER(
        SUMMARIZE(ALLSELECTED('Follow-Up Team'),'Follow-Up Team'[Errors],
            "Volume",'Follow-Up Team'[Error Volume]),
                [Volume] >= ErrorCount),
                    [Volume]),
    AllErrors,0)    

 

Below is the cooresponding table for a given filtered time period.

 

Errors          Error Volume          Running Total          Chart %

 #1                        9                              9                      26%

 #2                        8                             25                     71%
 #
3                        8                             25                     71%

 #4                        6                             31                     89%

 #5                        4                             35                    100%

 

I need the Running Total for Error #2 = 17 (9+8) and Chart % for Error #2 = 49%.

8 Replies

  • Hi,

    Please check the below picture and the attached pbix file.

     

     

     

    WINDOW function (DAX) - DAX | Microsoft Learn

     

    Running total: = 
    CALCULATE (
        SUM ( 'Follow-Up Team'[Error Volume] ),
        WINDOW (
            1,
            ABS,
            0,
            REL,
            ALL ( 'Follow-Up Team' ),
            ORDERBY (
                CALCULATE ( SUM ( 'Follow-Up Team'[Error Volume] ) ), DESC,
                'Follow-Up Team'[Errors], ASC
            ),
            ,
            ,
            MATCHBY ( 'Follow-Up Team'[Errors] )
        )
    )

     

    ratio: = 
    DIVIDE (
        [Running total:],
        CALCULATE ( SUM ( 'Follow-Up Team'[Error Volume] ), ALL ( 'Follow-Up Team' ) )
    )

     

  • mol_ad's avatar
    mol_ad
    Frequent Visitor

    While testing the provided solution, I am getting the below display error.

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi mol_ad ,

     

    May I ask what scenario you are testing? I used the solution provided by Jihwan_Kim  and everything shows up fine.

     

    Best Regards,
    Adamk Kong

    • mol_ad's avatar
      mol_ad
      Frequent Visitor

      I believe I have found the reason I was getting the error.  I only provided information that I was using after a filter and not the entire data source table.  Since this is first time I am posting, I have not yet figured out how to attach a file, so I will provide a sample of the excel file data source.

      *Note: I have provided 2 Users for a 3-Month sample, but I have a total 28 Users with more to be added in the future*

       

      Unique IdentifierUserSupervisorMonthErrorsError VolumeEfficiency ScoreQuarter
      T.B.-JanuaryT.B.Supervisor #1JanuaryTimeliness260%Q1
      T.B.-JanuaryT.B.Supervisor #1JanuaryAppropriate Activity Code0100%Q1
      T.B.-JanuaryT.B.Supervisor #1JanuaryAppropriate Notes180%Q1
      T.B.-JanuaryT.B.Supervisor #1JanuaryAppropriate Escalation180%Q1
      T.B.-JanuaryT.B.Supervisor #1JanuaryResolution0100%Q1
      T.B.-FebruaryT.B.Supervisor #1FebruaryTimeliness260%Q1
      T.B.-FebruaryT.B.Supervisor #1FebruaryAppropriate Activity Code260%Q1
      T.B.-FebruaryT.B.Supervisor #1FebruaryAppropriate Notes340%Q1
      T.B.-FebruaryT.B.Supervisor #1FebruaryAppropriate Escalation0100%Q1
      T.B.-FebruaryT.B.Supervisor #1FebruaryResolution180%Q1
      T.B.-MarchT.B.Supervisor #1MarchTimeliness340%Q1
      T.B.-MarchT.B.Supervisor #1MarchAppropriate Activity Code0100%Q1
      T.B.-MarchT.B.Supervisor #1MarchAppropriate Notes260%Q1
      T.B.-MarchT.B.Supervisor #1MarchAppropriate Escalation0100%Q1
      T.B.-MarchT.B.Supervisor #1MarchResolution180%Q1
      L.B.-JanuaryL.B.Supervisor #2JanuaryTimeliness180%Q1
      L.B.-JanuaryL.B.Supervisor #2JanuaryAppropriate Activity Code0100%Q1
      L.B.-JanuaryL.B.Supervisor #2JanuaryAppropriate Notes260%Q1
      L.B.-JanuaryL.B.Supervisor #2JanuaryAppropriate Escalation180%Q1
      L.B.-JanuaryL.B.Supervisor #2JanuaryResolution0100%Q1
      L.B.-FebruaryL.B.Supervisor #2FebruaryTimeliness340%Q1
      L.B.-FebruaryL.B.Supervisor #2FebruaryAppropriate Activity Code0100%Q1
      L.B.-FebruaryL.B.Supervisor #2FebruaryAppropriate Notes0100%Q1
      L.B.-FebruaryL.B.Supervisor #2FebruaryAppropriate Escalation0100%Q1
      L.B.-FebruaryL.B.Supervisor #2FebruaryResolution180%Q1
      L.B.-MarchL.B.Supervisor #2MarchTimeliness0100%Q1
      L.B.-MarchL.B.Supervisor #2MarchAppropriate Activity Code180%Q1
      L.B.-MarchL.B.Supervisor #2MarchAppropriate Notes340%Q1
      L.B.-MarchL.B.Supervisor #2MarchAppropriate Escalation260%Q1
      L.B.-MarchL.B.Supervisor #2MarchResolution0100%Q1

       

      This chart shows what I expect the table and therefore Pareto Chart to look like.

       

      Error                                     E.V.      .T.     Chart %

      Timeliness111134.38%
      Appropriate Notes112268.75%
      Appropriate Escalation42681.25%
      Appropriate Activity Code32990.63%
      Resolution332100.00%
      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi mol_ad ,

         

        You can try formula like below:

        Running Total = 
        VAR CurrentError =
            SELECTEDVALUE ( 'YourTableName'[Errors] )
        RETURN
            CALCULATE (
                SUM(YourTableName[Error Volume]),
                FILTER (
                    ALLSELECTED ( 'YourTableName'[Errors] ),
                    'YourTableName'[Errors] <= CurrentError
                )
            )
        ratio: =
        DIVIDE (
            [Running total],
            CALCULATE ( SUM ( 'YourTableName'[Error Volume] ), ALL ( 'YourTableName' ) )
        )
        

         

         

        Best Regards,
        Adamk Kong

         

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • mol_ad 

    Running Total =
    VAR CurrentError = MAX('Follow-Up Team'[Errors])
    RETURN
    CALCULATE(
    SUM('Follow-Up Team'[Error Volume]),
    FILTER(
    ALL('Follow-Up Team'[Errors]),
    'Follow-Up Team'[Errors] <= CurrentError
    )
    )

    • mol_ad's avatar
      mol_ad
      Frequent Visitor

      When using this formula, I am still running into the same problem.  When the errors are sorted alphabetically it is working as expected.  However, I am not sorting alphabetically - I am sorting by error volume (see the following):

       

      This is what I am looking for:

      Error                                     E.V.      R.T.     Chart %

      Timeliness111134.38%
      Appropriate Notes112268.75%
      Appropriate Escalation42681.25%
      Appropriate Activity Code32990.63%
      Resolution332100.00%

       

      Here is the resulting table I get when sorting the Errors by Error Volume using your given formula:

      ErrorsError VolumeRunning Total
      Appropriate Notes1118
      Timeliness1132
      Appropriate Escalation47
      Appropriate Activity Code33
      Resolution321
      Total32