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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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