Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hello, can you help me?
I would like to calculate the cumulative percentage of sales of my salespeople.
The expected result would be the yellow column.
If it had a date it would be easier, but my table is just that information, name of the seller and sales.
Link excel with formula and data.
Solved! Go to Solution.
You are going to need some way to know how to accumulate. I added an index column in Power Query (Add Column menu, Index.) Just make sure your data is sorted the way you want before you add the index. You are right, a date would make this easier, but the Index works just fine. I am not aware of a way to add such an index in DAX, and adding an index is a modeling issue anyway, so that really is best done in Power Query when possible.
Cumulative Percent =
VAR varCurrentIndex =
MAX( 'Table'[Index] )
VAR varGrandTotal =
SUMX(
ALL( 'Table' ),
'Table'[sales]
)
VAR varCumulativeTotal =
SUMX(
FILTER(
ALL( 'Table' ),
'Table'[Index] <= varCurrentIndex
),
'Table'[sales]
)
VAR Result =
DIVIDE(varCumulativeTotal,varGrandTotal,0)
RETURN
Result
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingYou are going to need some way to know how to accumulate. I added an index column in Power Query (Add Column menu, Index.) Just make sure your data is sorted the way you want before you add the index. You are right, a date would make this easier, but the Index works just fine. I am not aware of a way to add such an index in DAX, and adding an index is a modeling issue anyway, so that really is best done in Power Query when possible.
Cumulative Percent =
VAR varCurrentIndex =
MAX( 'Table'[Index] )
VAR varGrandTotal =
SUMX(
ALL( 'Table' ),
'Table'[sales]
)
VAR varCumulativeTotal =
SUMX(
FILTER(
ALL( 'Table' ),
'Table'[Index] <= varCurrentIndex
),
'Table'[sales]
)
VAR Result =
DIVIDE(varCumulativeTotal,varGrandTotal,0)
RETURN
Result
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI Reporting@edhans
Ouw, Perfect. So it worked perfectly, thank you very much. Would it be that instead of using the index, using rank in dax would work?
Maybe, but you would have to deal with the issues of a tie, which could be handled with the DENSE vs SKIP flag in RANKX. But it will for sure make the DAX more complex and possibly slow down the model depending on how many you are doing. 4-5, or 400-500 won't matter. If you get in to the thousands or tens of thousands, you'll see using RANKX start to slow things down for your visuals if used this way.
And I assume you know it would always do cumulative totals from highest to lowest (or reversed) vs how the data comes in.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingCheck out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
110 | |
95 | |
86 | |
78 | |
66 |
User | Count |
---|---|
157 | |
125 | |
116 | |
111 | |
95 |