Forum Discussion
How to Calculate Cumulative Percentage
I am trying to calculate a cumulative percentage i.e. row 1 will be 2.76% and row 2 will be 5.34% etc. % of Trips with Blank Driver is a measure and does not belong to a table. All other columns belong to a 'Vehicle' table
Any suggestion on how to create a column with a cumulative percentage would be very appreciated.
8 Replies
- Greg_Deckler
Community Champion
Imam01 You need something to define "previous" like a date or index. If you have that you can do this:
Cummulative Measure = VAR __Index = MAX('Vehicle'[Index]) VAR __Table = SUMMARIZE('Vehicle', [Index], [Vehicle License Plate], [Unique Vehicle ID], [Owner ID], "__PercentTrips", [% Trips with Blank Driver]) VAR __Result = SUMX( FILTER( __Table, [Index] <= __Index ), [__PercentTrips]) RETURN __Result- Imam01New Member
Greg_Deckler I've added this ranking system. How would this ranking system be implemented into the code you've commented?
Thanks- Greg_Deckler
Community Champion
Imam01 Is that a measure or a column?
- AnonymousNot applicable
Hi Imam01
As Greg_Deckler mentioned, you just need to change the [Index] to your own meaure /column name, and you can try the following measure.
If your fields are in the same table, you can try this.
Measure = VAR a = ADDCOLUMNS ( ALLSELECTED ( 'Vehicle' ), "Rank", [Top 10 Blank ID Vehicles Ranking], "%Trips", [% of Trips with Blank Driver] ) VAR b = [Top 10 Blank ID Vehicles Ranking] RETURN SUMX ( FILTER ( a, [Vehicle License Plate] IN VALUES ( 'Vehicle'[Vehicle License Plate] ) && [Rank] <= b ), [%Trips] )Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.