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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Set date slicer to YTD

 My date slicer has Year and Month. How can I set it so that it defaults to 2024 Jan through Jun (Jun being the current month)? 

 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @Anonymous 

You can try to see if this method meets your needs.

vyaningymsft_0-1719559646676.pngvyaningymsft_1-1719559658269.png


Measure:

Tag = 
VAR _date =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _tag =
    IF ( _date >= DATE ( 2024, 1, 1 ) && _date <= DATE ( 2024, 7, 1 ), 1, 0 )
VAR _choice = 
    SELECTEDVALUE( Choice[Choice] )

RETURN
    SWITCH(
        _choice,
        "DateFilter",_tag,
        "All Date",1
    )

 

Best Regards,
Yang

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. 
Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Vicky. I was just trying the "previous 45 days" and the "all" selections but it doesn't seem to be changes the selected date range. 

Anonymous
Not applicable

Hi, @Anonymous 

Thanks for @danextian @vicky_ reply. You can refer to their reply, if the ways are not meet your needs, you can refer to the following methods, set a flag to the slicer.

vyaningymsft_0-1718764028022.png

 

 

flag = 
VAR _date =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _tag =
    IF ( _date >= DATE ( 2024, 1, 1 ) && _date <= DATE ( 2024, 7, 1 ), 1, 0 )
RETURN
    _tag

 

 

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Anonymous
Not applicable

Yang, Your solution gave me this. This great for the default. How do I include additional months and years (greyed out)  in the list to give the user aditional choices?

Anonymous
Not applicable

Hi, @Anonymous 

If you are trying to show both selectable and non-selectable (grayed out) dates in Slicer, it is not supported in the current version. You can submit an idea for here and the product team will take note of such a need.

Related Link: New tab (powerbi.com)

 

Best Regards,
Yang

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

danextian
Super User
Super User

Hi @Anonymous ,

 

The native visual doesnt have such a feature. You can try:

using relative date filter in the filter pane

danextian_0-1718750241122.png

Or the custom viz Date Picker (needs a  license if used in the service)

danextian_1-1718750432421.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
vicky_
Super User
Super User

YTD = IF(
    'Calendar'[Date] <= EOMONTH(TODAY(), 0) && YEAR('Calendar'[Date]) = YEAR(TODAY()),
    "YTD", 
    FORMAT('Calendar'[Date], "mmm yyyy") // replace this with whatever you want
)

vicky__1-1718750006363.png

 

I have a daily calendar, but the idea is the calculated column YTD in the 2nd column has a YTD value that can be used as a default value in your slicer.

Anonymous
Not applicable

Is there a way to include Jan - Jun 2024 in the list? The user needs to be able to select any month if they don't want YTD.

Anonymous
Not applicable

Hi, @Anonymous 

You can try to see if this method meets your needs.

vyaningymsft_0-1719559646676.pngvyaningymsft_1-1719559658269.png


Measure:

Tag = 
VAR _date =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _tag =
    IF ( _date >= DATE ( 2024, 1, 1 ) && _date <= DATE ( 2024, 7, 1 ), 1, 0 )
VAR _choice = 
    SELECTEDVALUE( Choice[Choice] )

RETURN
    SWITCH(
        _choice,
        "DateFilter",_tag,
        "All Date",1
    )

 

Best Regards,
Yang

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. 
Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Anonymous
Not applicable

This seems like what I'm attempting to do. However I'm a bit confused by how it works. Are you able to provide it in the format of 2024,01,02,03....

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.