Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

set a filter to current month?

Hi, I am creating a simple report, where I want the user to open the latest month (by default).

 

How can I force this setting:

 

 

(now its ok, because I publish using april, but I want it to automatically be in FY22 - 12 - May when we are in may...)

  • Anonymous , You have to create  a new column like that to save on current month of this month

     

    Month Type = Switch( True(),
    eomonth([Date],0) = eomonth(Today(),-1),"Last Month" ,
    eomonth([Date],0)= eomonth(Today(),0),"This Month" ,
    [FY & Month]
    )

     

    as of now no function to get the value and save it

     

    Default Date Today/ This Month / This Year: https://www.youtube.com/watch?v=hfn05preQYA

2 Replies

  • Anonymous , You have to create  a new column like that to save on current month of this month

     

    Month Type = Switch( True(),
    eomonth([Date],0) = eomonth(Today(),-1),"Last Month" ,
    eomonth([Date],0)= eomonth(Today(),0),"This Month" ,
    [FY & Month]
    )

     

    as of now no function to get the value and save it

     

    Default Date Today/ This Month / This Year: https://www.youtube.com/watch?v=hfn05preQYA

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Power BI currently doesn't support us to set defualt filter in slicer or filter. I suggest you to create a measure as the visual level filter to filter your visual.

    I create a sample with data from 2022/01/01 to 2022/05/07. Based on your logic, my table visual will show value in Apr-2022 (current month) by default, and I can use filter or slicer to change the filter in this visual.

    Try this code.

    Measure = 
    IF(ISFILTERED(DimDate[FY & Month]) , 1, IF(MAX(DimDate[Year]) = YEAR(TODAY())&&MAX(DimDate[MonthNum]) = MONTH(TODAY()),1,0))

    Then add this measure into the visual level filter and set it to show items when value = 1.

    By Default:

    Select May in slicer.

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.