Forum Discussion
Help to calculate Commulative %
- Anonymous4 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
Due to intrinsic attribute of VertiPaq engine under the hood in PBI, rows are not literally ordinal in a table; that's to say, A1 doesn't preceed A2 at all. You must manually assign orders among categories.
Hi, Thank you for suporting.
How do we rank category in below case.
| Root Category | Category | ID |
| A | Cat | 2 |
| A | Cat | 12 |
| A | Cat | 22 |
| A | Rat | 4 |
| A | Tiger | 5 |
| A | Lion | 6 |
| A | Rat | 34 |
| A | Tiger | 55 |
| A | Pig | 7 |
| B | Cat | 8 |
| B | Rat | 9 |
| B | Tiger | 10 |
| B | Lion | 11 |
| B | Pig | 15 |
| B | Cat | 18 |
| B | Rat | 39 |
| B | Tiger | 70 |
- CNENFRNL4 years agoCommunity Champion
Exactly the same pattern,
- Anonymous4 years agoNot applicable
Thank you for support.
Please guide me to achve above requirement (rank the Root Category and Category) with DAX expression.
As additional tables can't be created in DM.
- Anonymous4 years agoNot applicable
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