Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Running Total of a Measure

Hi,

 

I have the following data:

 

Running Total.PNG

 

I need to calculate the running total of the measure '% of Value Claimed'. So something like this:

 

49.69%

74.69%

85.84%

89.17% etc

 

The DAX for the '% Of Value Claimed' measure is:

 

% Of Value Claimed = DIVIDE(SUM(ClaimLine[ClaimedAmt]); CALCULATE(SUM(ClaimLine[ClaimedAmt]); ALLSELECTED(ClaimLine)))
 
Any help appraciated.. Thanks

 

 

5 REPLIES 5
PaulDBrown
Community Champion
Community Champion

@Anonymous 

You can achieve this by using a combination of RANKX and TOPN.

See this example: this is a simple model calculating the cumulative values for "Actuals" by "Channel"
Resutl cumulative.JPG

 And here are the measures:

Sum of Actuals = SUM('Data Table'[Actuals])

 

RankX Actuals = 
VAR calc = RANKX(ALLSELECTED('Data Table'[Channel]);[Sum of Actuals];; DESC;Dense)
RETURN
IF(ISINSCOPE('Data Table'[Channel]); calc; BLANK())

 

And finally the cumulative values:

Cumulative Actuals = SUMX(TOPN([RankX Actuals]; 
                        ALLSELECTED( 'Data Table'[Channel]);[Sum of Actuals]; DESC); 
                            [Sum of Actuals])




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Hi @PaulDBrown,

 

Thanks for your input. Didn't work tho.:

 

Running Total 3.PNG

 

Measures are:

% Of Value Claimed = DIVIDE(SUM(ClaimLine[ClaimedAmt]);CALCULATE(SUM(ClaimLine[ClaimedAmt]);ALLSELECTED(ClaimLine)))
 
RankX % Value CLaimed =
VAR Calc = RANKX(ALLSELECTED(ClaimLine[ChargeCode]);[% Of Value Claimed];; DESC; Dense)
RETURN
IF(ISINSCOPE(ClaimLine[ChargeCode]); Calc; BLANK())
 
Cumulative % Value Claimed = SUMX(
TOPN(
   [RankX % Value CLaimed];
   ALLSELECTED(ClaimLine[ChargeCode]);[% Of Value Claimed]; DESC
);
[% Of Value Claimed]
 
Thanks
)

@Anonymous 

OK, well try using the sum of values instead of the percentages to get the cumulative, as in:
1) calculate total over all selected :

Total Actuals (selected) = CALCULATE([Sum of Actuals]; ALLSELECTED('Data Table'[Channel]))

2) Rank of values:

RankX Actuals = 
VAR calc = RANKX(ALLSELECTED('Data Table'[Channel]);[Sum of Actuals];; DESC;Dense)
RETURN
IF(ISINSCOPE('Data Table'[Channel]); calc; BLANK())


2) Cumulative Values:

Cumulative Actuals = SUMX(TOPN([RankX Actuals]; 
                        ALLSELECTED( 'Data Table'[Channel]);[Sum of Actuals]; DESC); 
                            [Sum of Actuals])

3) now divide the cumulative over the total:

Cumulative % Actuals = DIVIDE([Cumulative Actuals]; [Total Actuals (selected)])

And you get this:

Cumulative % actuals.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Gordonlilj
Solution Sage
Solution Sage

Hi,

 

You could try creating a running total quick measure and see if you get the result you need

 

Qucik1.PNG

 

quick2.PNG

 

 

Anonymous
Not applicable

Hi,

 

The use of the quick measure didn't work (See last column):

 

Running Total 2.PNG

 

The DAX for the Quick measure is:

 

% Of Value Claimed running total in ChargeCode =
CALCULATE(
    [% Of Value Claimed];
    FILTER(
        ALLSELECTED('ClaimLine'[ChargeCode]);
        ISONORAFTER('ClaimLine'[ChargeCode]; MAX('ClaimLine'[ChargeCode]); DESC)
    )
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.