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

Running total with a specific start value

I have a problem regarding running totals:

 

1. I have sales data for 2017 and 2018 for every day

2. I want a running total of 2018 with the start value of "Sum of sales 2017"

running total problem.PNG

1 ACCEPTED SOLUTION

@Anonymous Please try this as a "New Measure"

 

Test207 = 
VAR _2017Sales = CALCULATE(SUM(Test207RunningTotal[Sales]),FILTER(ALL(Test207RunningTotal),Test207RunningTotal[Year]=2017))
VAR _2018Sales = CALCULATE(SUM(Test207RunningTotal[Sales]),FILTER(ALL(Test207RunningTotal),Test207RunningTotal[Year]=2018 && Test207RunningTotal[Date] <= MAX(Test207RunningTotal[Date])))
RETURN IF(MAX(Test207RunningTotal[Year])=2018,_2017Sales + _2018Sales)

image.png





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

Proud to be a PBI Community Champion




View solution in original post

6 REPLIES 6
PattemManohar
Community Champion
Community Champion

@Anonymous  Please try this as a New Column

 

RunningTotal = 
VAR _2017Sales = CALCULATE(SUM(Test207RunningTotal[Sales]),FILTER(ALL(Test207RunningTotal),Test207RunningTotal[Year]=2017))
VAR _2018Sales = CALCULATE(SUM(Test207RunningTotal[Sales]),FILTER(ALL(Test207RunningTotal),Test207RunningTotal[Year]=2018 && Test207RunningTotal[Date] <= EARLIER(Test207RunningTotal[Date])))
RETURN IF(Test207RunningTotal[Year]=2018, _2017Sales+_2018Sales)

image.png





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

Proud to be a PBI Community Champion




Anonymous
Not applicable

Thank you @PattemManohar for your solution - I wonder if there is a generic solution with a measure since I prefer not to have a calculated column!

/Sebastian

@Anonymous Please try this as a "New Measure"

 

Test207 = 
VAR _2017Sales = CALCULATE(SUM(Test207RunningTotal[Sales]),FILTER(ALL(Test207RunningTotal),Test207RunningTotal[Year]=2017))
VAR _2018Sales = CALCULATE(SUM(Test207RunningTotal[Sales]),FILTER(ALL(Test207RunningTotal),Test207RunningTotal[Year]=2018 && Test207RunningTotal[Date] <= MAX(Test207RunningTotal[Date])))
RETURN IF(MAX(Test207RunningTotal[Year])=2018,_2017Sales + _2018Sales)

image.png





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

Proud to be a PBI Community Champion




Anonymous
Not applicable

@PattemManohar - you are a god! 🙂

Thank you so much for your time and your help - it's a solution I really needed, thank you!

🙂

Anonymous
Not applicable

@PattemManohar do you jnow how to do this if the sales for the different years were in different tables?

@Anonymous  If you have year wise sales in different tables, then append those into single table using "Append" in Power Query or use "UNION" function in DAX. That will result into single table with overallsales data at one place.





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

Proud to be a PBI Community Champion




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.