Forum Discussion

vinodDrinkPak's avatar
vinodDrinkPak
Helper II
2 years ago

default dropdown date to current month

Hi Experts

 

default value of my end of month Dropdown is 'All", i want to have a dynamic way to always have the selected default value as current month, how do i achieve this?

 

My date table using a DAX logic

 

Dates(Disconnected)M =
FILTER(DISTINCT(LOCATION_INVENTORY[End of Month]),NOT(ISBLANK(LOCATION_INVENTORY[End of Month])))

 

 

4 Replies

  • JoeBarry's avatar
    JoeBarry
    Solution Sage

    Hi vinodDrinkPak 

     

    Please try

     

     

    In your date table add a new column

     

    Current Month = if(Month('DIM Date'[Date]) = MONTH(TODAY()) ,1, 0)

     

    Add a slicer with the normal date column in it. in the filter bar add the new column and choose filter type Basic filtering and choose 1 and apply filter 

     

    Thanks

    Joe

     

    If this post helps, then please Accept it as the solution

    • vinodDrinkPak's avatar
      vinodDrinkPak
      Helper II

      JoeBarry 

      with that approach i will only be able to  see current month dropdown, i just want to keep the Current month as default and still show all the previous months, see below based on the logic you shared

       

       

      • vinodDrinkPak's avatar
        vinodDrinkPak
        Helper II

        JoeBarry 

        i figured out a way

         

        Current Month =
        VAR CurrentMonth = MONTH(TODAY())
        VAR CurrentYear = YEAR(TODAY())
        VAR DateMonth = MONTH('Dates(Disconnected)M'[End of Month])
        VAR DateYear = YEAR('Dates(Disconnected)M'[End of Month])
        RETURN
            IF(DateMonth = CurrentMonth && DateYear = CurrentYear, "Current Month", FORMAT('Dates(Disconnected)M'[End of Month], "mmm-yy"))
         
        CustomSort =
        VAR CurrentMonthValue = 1000
        VAR CurrentMonthYear = YEAR(TODAY())
        VAR MonthToEndYear = YEAR('Dates(Disconnected)M'[End of Month])
        VAR MonthToEndMonth = MONTH('Dates(Disconnected)M'[End of Month])
        VAR MonthsDifference = (CurrentMonthYear - MonthToEndYear) * 12 + (MONTH(TODAY()) - MonthToEndMonth)
        RETURN
            CurrentMonthValue - MonthsDifference
         
        i used 2 logics and it resolved