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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
snoya
Frequent Visitor

Calendar table for YTD and LYTD calculations

Hi,

I am trying to implement YTD and LYTD. I have fact table which has a date column and a calendar table related.

 

I used YTD calculation as like below:

 

YTD  = TOTALYTD(SUM('Fact'[Amount]),'Calendar'[Date])

 

 When I use TOTALYTD formula its calculating entire year, because I have in the calendar table all days until the last day of the actual year. I expected ytd shows data until today.

 

How can I trim the calendar though dax to show data until a given date or the last day that exists data in the fact table?

 

Thank you. 

1 ACCEPTED SOLUTION

Hi,

 

I removed the Amount column from your visual and created a measure called Amount1

 

=SUM(FT[AMOUNT])

I then modified your YTD measure to:

 

=if(ISBLANK([Amount1]),BLANK(),TOTALYTD([Amount1],DIM_DATE[DATE]))

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

 

Can you show a screenshot of the problem that you are facing.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

Thank you for your response. I expect YTD for the prior year and actual calculate up to July which is the last month where exists data.

Captura.PNG

 Captura.PNG

Hi,

 

If your actual data is only till July 2017, then why is there a value of 10 under the Amount column all the way uptil December 2017.  Please share a link from where i can download your workbook.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

That is the issue. I dont know why TOTALYTD has that behaviour. The fact table has data until July 2017 but calenadr table has data until December.

 

Here is the link.

 

https://drive.google.com/open?id=0Bx6w6EXk0yFhSmx2eWZNTHVyWmM

 

 

Hi,

 

I removed the Amount column from your visual and created a measure called Amount1

 

=SUM(FT[AMOUNT])

I then modified your YTD measure to:

 

=if(ISBLANK([Amount1]),BLANK(),TOTALYTD([Amount1],DIM_DATE[DATE]))

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

It Works! For the LYTD measure the formula is

 

if(ISBLANK([Total Amount]),BLANK(),TOTALYTD(Amount1,SAMEPERIODLASTYEAR(DIM_DATE[DATE])))

Thank you for your time. 

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.