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
BenediktW
Advocate I
Advocate I

Cumulative % Total in Canvas

Hello together,

 

I have a datamodel, which contains sales and customers. In the visualisations I have a table with sales by customers. 

Now I would like to calculate a running cumulative total for the prozentual sales per customer based on the total sales.

 

This I tried to do with an measure, as this table sales per customer should be filterable (e.g. choose different years).

This formular was working best for me so far, but I just get the % sales per customer based on total sales. and not the running total. Result should be something like this: 

CustomersUmsatz Cumulative % Total
Customer1x4,30%4,30%
Customer2y2%6,30%
Customer3z1,50%7,80%

 

VAR CurrentCustomer = MAX('myTable'[Customer])
VAR TotalSales = CALCULATE(SUM('mytable'[Sales]), ALLSELECTED('mytable'))
VAR CustomerSales = CALCULATE(SUM('mytable'[Sales]), ALLEXCEPT('myTable', 'myTable'[Customer]))
VAR CumulativeSales =
    CALCULATE(
        SUM('mytable'[Sales]),
        FILTER(
            ALLSELECTED('myTable'[Customer]),
            RANKX(ALL('myTable'[Customer]), SUM('mytable'[Sales]), , DESC) <= RANKX(ALL('myTable'[Customer]), SUM('mytable'[Sales]), , DESC)
                && 'myTable'[Customer] <= CurrentCustomer
        )
    )

RETURN
DIVIDE(CumulativeSales, TotalSales)
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @BenediktW 

 

Based on the code you provided, you seem to be calculating the total sales and sales per customer correctly.

 

However, accumulating sales seems to be the problem. To calculate the running cumulative percentage, you need to make sure that the cumulative sales are calculating the cumulative values correctly in the table.

 

I made some simple changes to your code.

 

Here's some dummy data.

 

"Table"

vnuocmsft_0-1711001212870.png

 

Modified code:

 

Cumulative % Total = 
var currentCustomer = MAX('Table'[Customers])
var TotalSales = 
    CALCULATE(
        SUM('Table'[Sales]), 
        ALLSELECTED('Table')
    )
var CumulativeSales = 
    CALCULATE(
        SUM('Table'[Sales]), 
        FILTER(
            ALLSELECTED('Table'), 
            'Table'[Customers] <= currentCustomer
        )
    )
RETURN DIVIDE(CumulativeSales, TotalSales)

 

 Here is the result.

 

vnuocmsft_1-1711001297302.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @BenediktW 

 

Based on the code you provided, you seem to be calculating the total sales and sales per customer correctly.

 

However, accumulating sales seems to be the problem. To calculate the running cumulative percentage, you need to make sure that the cumulative sales are calculating the cumulative values correctly in the table.

 

I made some simple changes to your code.

 

Here's some dummy data.

 

"Table"

vnuocmsft_0-1711001212870.png

 

Modified code:

 

Cumulative % Total = 
var currentCustomer = MAX('Table'[Customers])
var TotalSales = 
    CALCULATE(
        SUM('Table'[Sales]), 
        ALLSELECTED('Table')
    )
var CumulativeSales = 
    CALCULATE(
        SUM('Table'[Sales]), 
        FILTER(
            ALLSELECTED('Table'), 
            'Table'[Customers] <= currentCustomer
        )
    )
RETURN DIVIDE(CumulativeSales, TotalSales)

 

 Here is the result.

 

vnuocmsft_1-1711001297302.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

DataInsights
Super User
Super User

@BenediktW,

 

Have you tried the new preview feature Visual Calculations? They provide a simpler way of calculating things like cumulative totals. You'll need to enable this preview feature in Power BI Desktop.

 

https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-visual-calculations-overview 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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