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

Cumulative Sum, DAX

Hi all,

 

I'm having trouble creating a calculated column (or measure) in DAX that will return a running total based on groups.  The data I'm working with looks like this:

Capture.JPG

 

I need the Requirement Quantity summed up as a running total, which would start over every time the 'Item Number' field changes.  As you can see, I've also added a Conditional Index field through M Query.  But I've tried almost every single DAX formula I've found on this forum and elsewhere and have had absolutely no luck with it.  I managed to create a running total in M Query, but the query takes hours to refresh.  Any ideas on how I can solve this?  Thanks in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

This is my ussual way of calculating running totals but it should do the trick for you aswell.

Calculated column =
CALCULATE (
    SUM ( 'Table'[Requirement quantity] );
// Calculate over the entire table ALL ( 'Table' );
// Filter where item numbers are the same 'Table'[Item Number] = EARLIER ( 'Table'[Item NumberT] );
// Filter the order for calculating 'Table'[Index] <= EARLIER ( 'Table'[Index] ) )

Always here to help.

Kind regards

Joren Venema

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

This is my ussual way of calculating running totals but it should do the trick for you aswell.

Calculated column =
CALCULATE (
    SUM ( 'Table'[Requirement quantity] );
// Calculate over the entire table ALL ( 'Table' );
// Filter where item numbers are the same 'Table'[Item Number] = EARLIER ( 'Table'[Item NumberT] );
// Filter the order for calculating 'Table'[Index] <= EARLIER ( 'Table'[Index] ) )

Always here to help.

Kind regards

Joren Venema

Anonymous
Not applicable

Thanks Joren, this worked!  You're the man!!!

Nathaniel_C
Super User
Super User

Total Requirement measure = SUM(table[Requirement Quantity])
======================================================
Total Cumulative =
VAR MaxDate =
    MAX ( table[Requirement Date] ) -- Saves the last visible date
VAR ReqQuantity =
    CALCULATE (
        [Total Requirement measure],
        -- Computes hours
        table[Requirement Date] <= MaxDate,
        -- Where date is before the last visible date
        ALLEXCEPT (
            table,
            table[Buyer Group ]
        )
    )
RETURN
    ReqQuantity

Hi @Anonymous 
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





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

Proud to be a Super User!




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.