Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Default selected value in date slicer

I have a slicer that presents year-month (from my date table).

I want the slicer to be default filtered (selection) on the current month, but the user need to be able to select other months as well.

There is a column CurrentMonth (yes/no) in the date table that might help me?

5 Replies

  • selimovd's avatar
    selimovd
    Icon for Most Valuable Professional rankMost Valuable Professional

    Hey Anonymous ,

     

    yes, you can add a calculated column that is checking for the current month. This you can activate as a slicer.

    Check the following article on how to do that:

    Automatically filter report on actual date with calculated column and with measure - What the fact.bi

     

    If you need any help please let me know.
    If I answered your question I would be happy if you could mark my post as a solution โœ”๏ธ and give it a thumbs up ๐Ÿ‘
     
    Best regards
    Denis
     
    • Anonymous's avatar
      Anonymous
      Not applicable

      Not sure if it works

      I have two slicers below, one for yearmonth and one for the IsPreviousMonth flag (see screenshot)

      The values are in swedish (2021 juli means 2021 july and Ja/Nej means Yes/No).

       

      When the IsPreviousMonth = yes is selected the YearMonth slicer is filtered but the value is not selected.

      Apart from that I also want the user to see all values for YearMonth

       

       

  • v-luwang-msft's avatar
    v-luwang-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

    By the  picture you provided,try the below steps:

    Then  the Slicer Yearmon is not affected by Slicer mon.

     

    And I think you could try the following soultion:

    create a new measuere:

    values2 = 
    var test1=
        CALCULATE (
            MAX ( 'Table'[value] ),
            FILTER (  'Table' , month('Table'[date])=MONTH(NOW())-1&&YEAR('Table'[date])=YEAR(NOW()))
        ) var test2=
        CALCULATE (
            MAX ( 'Table'[value] ),
            FILTER (  'Table' , 'Table'[yearmon] = SELECTEDVALUE ( 'Table'[yearmon] ) )
        )
     return  IF( ISFILTERED( 'Table'[yearmon]) = True() , test2,test1)

    then create visual ,the visual  default to last month's data when the slicer is not selected.

     

    Wish it is helpful for you!

     

    Best Regards

    Lucien

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks, that will certainly work but there are many (more than 30) measures that needs to be adjusted.

  • v-luwang-msft's avatar
    v-luwang-msft
    Icon for Community Support rankCommunity Support

    HI  Anonymous ,

    Has your problem been solved, if so, please consider Accept a correct reply as the solution or share your own better  solution to help others find it.

     

    Best Regards
    Lucien