Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

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
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, Anonymous 

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


    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