Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Help to calculate Commulative %

Hi All,

I have below table.

Root CategoryCategoryCount of ID
AA1142
 A269
 A325
 A417
 A516
 A85

 

Requirement is to calcualte cummulative total and cummulate % as below. Please guide me 

 

Root CategoryCategoryCount of IDCumulative TotalCumulative Percentage
AA114214252%
 A26921177%
 A32523686%
 A41725392%
 A51626998%
 A85274100%

 

Thanks in advance.

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

    What connection mode data source your report is connected to? I saw you mention that you can't create additional tables in DM, is the data source in DQ or LC connection mode? Or are you unable to create additional tables in DM for some other reason?

    I have created an sample pbix file(see attachment), please check if it is what you want.
    1. Create a calculated column to get the index base on Root Category and Category fields (It is necessary for the cumulative calculation later, use it as a base column for the cumulative calculation)

    Index = RANKX ( 'Table', 'Table'[Category],, ASC, DENSE )

    2. Create two measures to get the cumulative value and cumulative percentage respectively

    Cumulative Total = 
    VAR _tab =
        SUMMARIZE (
            'Table',
            'Table'[Root Category],
            'Table'[Category],
            "@sumofid",
                CALCULATE (
                    SUM ( 'Table'[ID] ),
                    FILTER (
                        ALLEXCEPT('Table','Table'[Root Category]),
                        'Table'[Index] <= SELECTEDVALUE ( 'Table'[Index] )
                    )
                )
        )
    RETURN
        MAXX ( _tab, [@sumofid] )
    Cumulative Percentage = 
    DIVIDE (
        [Cumulative Total],
        CALCULATE ( SUM ( 'Table'[ID] ), ALLEXCEPT ( 'Table', 'Table'[Root Category] ) ),
        0
    )

    Best Regards

10 Replies

  • Anonymous , Create 2 measures like below:

    Total Cumulative = CALCULATE(SUM('Table'[Count of ID]),FILTER(ALL('Table'),'Table'[Category]<=MAX('Table'[Category])))
     
    Cumulative % = 
    DIVIDE([Total Cumulative],CALCULATE(SUM('Table'[Count of ID]),ALL('Table')))
     
      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Tahreem.

         

        "Count of ID" is not a direct field. 

        Count of ID = Count(ID). how to use this in above expression.

         

        Thanks in Advance