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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
rdy_okay
Regular Visitor

Percentage Running Total of Groups With Slicers

I am new to this community and new to Power BI, so please let me know if there is already information available to help me figure this one out on my own. I've searched for a solution the last few days, but I haven't been able to find it, yet.

 

I used sample data to create the following matrix:

 

rdy_okay_0-1658960586741.png

I would like to include a column that shows a running percentage of countries in each segment that updates with slicers that filter year and/or month:

 

rdy_okay_1-1658960684152.png

Could someone please point me in the right direction? Any assistance would be greatly appreciated.

 

Here is my pbix with sample data: ABCexample.pbix 

Here is the Excel file that has the setup I am looking for: pivotABC.xlsx 

 

1 ACCEPTED SOLUTION

Happy to help!

 

Yes, changing the sort order requires the measure to be adjusted. Here the measure is based on gross sales (from high to low).

% Running Total in Country v2 = 
VAR CurrentCountry =
    SELECTEDVALUE ( Sheet1[Country] )
VAR AllCountries =
    ALLSELECTED ( Sheet1[Country] )
VAR RankCountries =
    ADDCOLUMNS (
        AllCountries,
        "@Rank", RANKX ( AllCountries, CALCULATE ( SUM ( Sheet1[Gross Sales] ) ),, DESC )
    )
VAR CurrentRank =
    MAXX ( FILTER ( RankCountries, Sheet1[Country] = CurrentCountry ), [@Rank] )
VAR RunningSales =
    SUMX (
        FILTER ( RankCountries, [@Rank] <= CurrentRank ),
        CALCULATE ( SUM ( Sheet1[Gross Sales] ) )
    )
VAR TotalSales =
    CALCULATE ( SUM ( Sheet1[Gross Sales] ), REMOVEFILTERS ( Sheet1[Country] ) )
VAR Result =
    DIVIDE ( RunningSales, TotalSales )
RETURN
    Result

If you want it from low to high, please rewrite 'DESC' in the code to 'ASC'.

This should be your result:

Barthel_0-1659020143734.png

 

View solution in original post

4 REPLIES 4
Barthel
Solution Sage
Solution Sage

Hey,

 

Give this measure a try:

 

% Running Total in Country =
VAR CurrentRank =
    SELECTEDVALUE ( Sheet1[Country] )
VAR RunningSales =
    CALCULATE (
        SUM ( Sheet1[Gross Sales] ),
        REMOVEFILTERS ( Sheet1[Country] ),
        Sheet1[Country] <= CurrentRank
    )
VAR TotalSales =
    CALCULATE ( SUM ( Sheet1[Gross Sales] ), REMOVEFILTERS ( Sheet1[Country] ) )
VAR Result =
    DIVIDE ( RunningSales, TotalSales )
RETURN
    Result


% Running Total is always based on alphabetical order of the countries. Is this what you want?

Barthel_0-1658992917327.png

 

Thank you so much for your reply!

 

I'm glad you brought up that the current setup was alphabetical by country. That was definitely a mistake on my part. My original data is ordered by Gross Sales descending and that is what I meant to do in my example. Your measure works perfectly for the scenario I posted.

 

Does changing the sorting require completely changing the logic of the measure? I'm playing with it now to see if I can do it myself, but haven't figured it out, yet. 

 

Thank you, again.

Happy to help!

 

Yes, changing the sort order requires the measure to be adjusted. Here the measure is based on gross sales (from high to low).

% Running Total in Country v2 = 
VAR CurrentCountry =
    SELECTEDVALUE ( Sheet1[Country] )
VAR AllCountries =
    ALLSELECTED ( Sheet1[Country] )
VAR RankCountries =
    ADDCOLUMNS (
        AllCountries,
        "@Rank", RANKX ( AllCountries, CALCULATE ( SUM ( Sheet1[Gross Sales] ) ),, DESC )
    )
VAR CurrentRank =
    MAXX ( FILTER ( RankCountries, Sheet1[Country] = CurrentCountry ), [@Rank] )
VAR RunningSales =
    SUMX (
        FILTER ( RankCountries, [@Rank] <= CurrentRank ),
        CALCULATE ( SUM ( Sheet1[Gross Sales] ) )
    )
VAR TotalSales =
    CALCULATE ( SUM ( Sheet1[Gross Sales] ), REMOVEFILTERS ( Sheet1[Country] ) )
VAR Result =
    DIVIDE ( RunningSales, TotalSales )
RETURN
    Result

If you want it from low to high, please rewrite 'DESC' in the code to 'ASC'.

This should be your result:

Barthel_0-1659020143734.png

 

That did it! Thank you again!

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.