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
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
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.