Forum Discussion
Imam01
2 years agoNew Member
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 belo...
Greg_Deckler
Community Champion
2 years agoImam01 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
__ResultImam01
2 years agoNew Member
Greg_Deckler I've added this ranking system. How would this ranking system be implemented into the code you've commented?
Thanks
- Greg_Deckler2 years ago
Community Champion
Imam01 Is that a measure or a column?
- Imam012 years agoNew Member
Greg_Deckler It is a measure.
- Greg_Deckler2 years ago
Community Champion
Imam01 OK, well then maybe this. Also, left out the very important ALL or ALLSELECTED from previous reply but it is in this one:
Cummulative Measure = VAR __Index = [_Top 10 Blank ID Vehicles Ranking] VAR __Table = SUMMARIZE(ALL('Vehicle'), [Index], [Vehicle License Plate], [Unique Vehicle ID], [Owner ID], "__PercentTrips", [% Trips with Blank Driver], "__Index", [_Top 10 Blank ID Vehicles Ranking]) VAR __Result = SUMX( FILTER( __Table, [__Index] <= __Index ), [__PercentTrips]) RETURN __Result