Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Need to calculate ytd running total to calculate the running total till the max month of the data

Hi thereytd-total.PNG,

 

  I am trying to write a measure which can calculate the running totals across months of various years. I am somehow getting accurate result with my formula but the only problem with my formula is that it is calculating or rather copy pasting the same amount in the months that are not present in my data.

 

  My data has sales till 31-01-2016 but somehow the running total formula which i wrote is calculating the running total for feb ,march & so on till december but copy pasting the january sales total in all months.

 

here is what i tried.

 

Runningtotal_YTD = calculate(sale,datesytd(datekey(date)))

 

I also tried 

 

runningtotal_YTD= Totalytd(sales,datekey(date)).

 

Both formula are fetching the identical results. 

 

How can i resolve it??

1 ACCEPTED SOLUTION
sdjensen
Solution Sage
Solution Sage

@Anonymous you could try something like this

 

Runningtotal_YTD = 
IF ( MIN( datekey(date) <= MAX(facttable[datecolumn]);
calculate(sale,datesytd(datekey(date)))
)
/sdjensen

View solution in original post

4 REPLIES 4
sdjensen
Solution Sage
Solution Sage

@Anonymous you could try something like this

 

Runningtotal_YTD = 
IF ( MIN( datekey(date) <= MAX(facttable[datecolumn]);
calculate(sale,datesytd(datekey(date)))
)
/sdjensen
Anonymous
Not applicable

thanx @sdjensen: This way around worked more than perfectly. 

 

Regards

MattAllington
Community Champion
Community Champion

The easiest way to solve the problem is to make sure your calendar table doesn't extend past your data. I wrote a blog about it here. 

 

http://www.powerpivotpro.com/2015/02/create-a-custom-calendar-in-power-query/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
Anonymous
Not applicable

Hi @MattAllington

 My sincere thanks for reverting to my both queries. I read your blog & it is really helpful but it is a solution in power query whereas my Problem is that i have already created a date table within DAX & has made numerous calculated column too under it. Can you suggest some way to dynamically control end date in within Power BI using DAX??

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors