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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Set up a slicer at default value (current month) and calculate YTD

Hello,

 

I used the method like below to set up the slicer as default value - current month.  https://community.powerbi.com/t5/Desktop/Setting-the-Default-Value-of-a-Slicer/td-p/16442

 

However, I also need to calculate YTD numbers and it doesn't work.  please see below tables, is there any way to solve that? Thank you!

 

The YTD function is 

YTD = TOTALYTD(SUM([#]), [As Of Date])

 

question.png

 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @vmao

 

You need to create a measure as below:

Measure = CALCULATE(SUM('Table'[#]),FILTER(ALL('Table'),'Table'[As Of Date]<=MAX('Table'[As Of Date])&&YEAR('Table'[As Of Date])=YEAR(MAX('Table'[As Of Date]))))

 

As in the column of "Current Month", the data type is text, not a date type,so when you use a time intelligence function, you need to add a filter,to set a date range to make it calculate in context.Otherwise ,it will return a value of the current row.

 
Best Regards,
Kelly
 
Did I answer your question? Mark my post as a solution!

 

View solution in original post

5 REPLIES 5
v-kelly-msft
Community Support
Community Support

Hi @vmao

 

You need to create a measure as below:

Measure = CALCULATE(SUM('Table'[#]),FILTER(ALL('Table'),'Table'[As Of Date]<=MAX('Table'[As Of Date])&&YEAR('Table'[As Of Date])=YEAR(MAX('Table'[As Of Date]))))

 

As in the column of "Current Month", the data type is text, not a date type,so when you use a time intelligence function, you need to add a filter,to set a date range to make it calculate in context.Otherwise ,it will return a value of the current row.

 
Best Regards,
Kelly
 
Did I answer your question? Mark my post as a solution!

 

Anonymous
Not applicable

Thank you!

 

The reason I am using  'current month' is because our data refreshed on a monthly basis, and I want viewer to always see the current month when they open the Power BI report. If I choose 'Jan 31, 2020' and when they open the report next month, the default value still shows Jan and they have to manually click to get Feb for the most recent date.

 

That is why the 'current month'  method is chosen which also makes TOTALYTD function is unavilable. 

 

If I drop 'current month' method, how could I make the most recent month as default selection choice in the report?

 

Details of the method see below:

https://community.powerbi.com/t5/Desktop/Setting-the-Default-Value-of-a-Slicer/td-p/16442

 

Hi @Anonymous,

 

No need to drop the 'current month'  method,just correct your measure as I suggested in my last post.What I wrote is to tell you the reason why the measure you use doesnt work.

 

Best Regards,
Kelly
 
Did I answer your question? Mark my post as a solution!
Greg_Deckler
Community Champion
Community Champion

Hard to tell exactly as can't create a test model. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

However, I am guessing that your slicer is filtering your date table and hence TOTALYTD only has that date within its context or something along those lines. 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thank you!

 

The reason I am using  'current month' is because our data refreshed on a monthly basis, and I want viewer to always see the current month when they open the Power BI report. If I choose 'Jan 31, 2020' and when they open the report next month, the default value still shows Jan and they have to manually click to get Feb for the most recent date.

 

That is why the 'current month'  method is chosen which also makes TOTALYTD function is unavilable. 

 

If I drop 'current month' method, how could I make the most recent month as default selection choice in the report?

 

Details of the method see below:

https://community.powerbi.com/t5/Desktop/Setting-the-Default-Value-of-a-Slicer/td-p/16442

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors