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
tutuk28
Helper IV
Helper IV

Timeline Slicer + YTD Measure

Hello, everybody!

I am using the Timeline Slicer in the months and I am having a problem in the current year (2020).

I have filtered the display to only show me the months that have values, that's why it shows me from January to April.

The problem is that when I select from January to April, it compares the whole year of the YTD which is incorrect. I should only consider myself until April:

 

1.PNG


How could I solve this problem in DAX?

Basically I don't want to be added to the accumulated value of the months of the current year that have not yet passed.

Thank you!

Regards!

1 ACCEPTED SOLUTION

@tutuk28 ,

Please refer to this file, if this can help. Check the calculation of LYTD, LYD2 vs others

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

9 REPLIES 9
amitchandak
Super User
Super User

@tutuk28 , try like

YTD Sales = 
var _max =today()
return
CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31"),'Date'[Date]<=_max)


Last YTD Sales = = 
var _max =date(year(today())-1,month(today()),day(today()))
return
CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"),'Date'[Date]<=_max)
Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Greg_Deckler
Super User
Super User

What is the calculation you are using? Are you using SAMEPERIODLASTYEAR?

 

See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi 

I am using the SAMEPERIODYEAR, but I think the problem is the Time Slicer that even if I select from January to April it takes me the whole year.

If I select from January to March the values in the table are correct:

3.PNG

 

But when I select from January to April it takes me the whole year and that's the problem I have.

4.PNG

Thanks

@tutuk28 ,

Not tested. try like

Last YTD Sales = = 
var _max =date(year(today())-1,month(today()),day(today()))
return
CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]),'Date'[Date]<=_max)
Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak 

The problem in this way is that if a particular month was selected (example only February) it does not accumulate the value of January, because it does not have the YTD.

Slicer selects me every month from January to December even if I have a filter that shows me only the months that have values.
And in this particular case they ask me to see all the measurements in YTD and they want to see that slicer.

Thanks!

I would skip time intelligence and just do it the way that works: Time Intelligence the Hard Way allows you to specifically control how you do your time calculation.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@tutuk28 , I suggested a couple of solutions. In case it still does not help.Can you share sample data and sample output.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak  ! Sorry it took me so long to respond.


I'll try to explain the problem better:

When I take measurements with YTD and YTD-1 and the year is complete (2018, 2019) I have no problem.

The problem appears in the current year which is still incomplete (2020).
The problem is particularly in the slider of months, if I select "select all", even if it is in the year 2020 (and has a flag that shows me only the months that have values) it selects me from January to December. That's why it gives me incorrect values (because for YTD-1 it accumulates all the values until December).
In case I don't use the DATESYTD for YTD-1 and only use the SAMEPERIODLASTYEAR as you told me, when I select only one month (example March 2020) it doesn't show me the accumulated of the year.

 

Thanks for your help !

@tutuk28 ,

Please refer to this file, if this can help. Check the calculation of LYTD, LYD2 vs others

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.