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

DAX formula to Calculate Column Cumulative Total

Hello, I am trying to add a calculated column to the dataset so that I can plot a line graph that shows cumulative total cost by week or month. It this possible given that there are several lines that makes the total for the week?

 

Capture2.PNG

 

 

Capture3.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, Thank you, I couldn't not make it work, but the following worked:

 

New Measure

 

Running Total=

CALCULATE(Sum(Table[Total Cost]),

                ALL('Table'),Table[Work Date]<=EARLIER(Table[Work Date]))

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hello, 

 

I am trying to develop a measure to calculate cumulative total for a specific year, in that case, for 2019. and I am doing this formula but I doesn't work: 

 

VAR CUMULATIVE2019 =
CALCULATE([Sales];DATESBETWEEN('Calendar'[year];DATEADD(LASTDATE('Calendar'[year]);1;YEAR);LASTDATE('Calendar'[year])))
RETURN
IF([Sales]<>BLANK();CUMULATIVE2019)
 
Can you help me please? 
 
Thank you

 

none of these solutions work, when you do not want to use a date.  I have an index column and it still doesnt work.  I get the Earlier/Earliest refers to an earlier row which doesn't exist. error.

Greg_Deckler
Super User
Super User

Basically something like this:

 

Cumulative Total = 
VAR myDate = MAX([Work Date])
VAR myMonth = MONTH(myDate)
VAR tmpTable = FILTER(ALL(Table),[Month no.] <=myMonth)
RETURN SUMX(tmpTable,[Total Cost])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi, Thank you, I couldn't not make it work, but the following worked:

 

New Measure

 

Running Total=

CALCULATE(Sum(Table[Total Cost]),

                ALL('Table'),Table[Work Date]<=EARLIER(Table[Work Date]))

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.