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
lebroyeur
Regular Visitor

Cumulative total and order

Hello everyone,

 

I am new to powerBI and I'm struggling to create a running total.

 

I only have one table, that looks like this :

 

                        SALES

MARKET A          100

MARKET A          50

MARKET B           30

MARKET C          600

MARKET C          400

MARKET D          700

 

What I need is a running total that would be ordered by number of sales per market (going from larger to smaller market), like this :

 

                          SALES.             RUN-TOTAL

MARKET A          150                  1850

MARKET B           30                   1880

MARKET C          1000                1000

MARKET D          700                  1700

 

Using quick measures, I have only been able to create running total ordered by market name, like this :

 

                          SALES.             RUN-TOTAL

MARKET A          150                  150

MARKET B           30                   180

MARKET C          1000                1180

MARKET D          700                  1880

 

I have also tried some things in DAX, but I am not familiar enough with it yet.

 

Thank you in advance !

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

2 REPLIES 2
wdx223_Daniel
Super User
Super User

mahoneypat
Employee
Employee

Here is a measure expression that gets your desired result.

 

RT Market =
VAR vThisMarket =
    MIN ( Sales2[Market] )
VAR vSummary =
    ADDCOLUMNS (
        ALLSELECTED ( Sales2[Market] ),
        "cSales",
            CALCULATE (
                SUM ( Sales2[Sales] )
            )
    )
VAR vThisSales =
    SUMX (
        FILTER (
            vSummary,
            Sales2[Market] = vThisMarket
        ),
        [cSales]
    )
RETURN
    SUMX (
        FILTER (
            vSummary,
            [cSales] >= vThisSales
        ),
        [cSales]
    )

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.

Top Solution Authors