Forum Discussion

Koritala's avatar
Koritala
Post Patron
10 months ago
Solved

Custom Date Range Slicer

Hi,

Could you help me with the scenario below?

 

I want to dynamically show the 2 differnt date slicers based on slicer value slection.

 

In slicer, I should have 2 values, one is MTD, second one is custom.

 

If user select MTD option in the slicer, it should return the date range slicer and it should enable the dates range from 1st of current month to till current date( For history and future dates, it should not allow user to select)

If user select custom in the slicer, it should display date range slicer without any restrictions(like should allow all history and future dates as well).

Can any one share the sample pbxi file?

 

Thanks,

Sri

  • Koritala's avatar
    Koritala
    9 months ago

    Hi Ugendar,
    Thanks for your solution. it working as expected.

15 Replies

  • Short version: you can’t “re-program” a single Date slicer so that its selectable range changes based on another slicer. Slicers only accept column filters, not measure logic, so they can’t react that way.

    You have two practical patterns:

     

    A) Best UX (two slicers + bookmarks)

     

    1. Create a disconnected selector:

     

    Mode =
    DATATABLE ( "Mode", STRING, { { "MTD" }, { "Custom" } } )

     

    2. Put two Date slicers on the page:

    • Slicer 1 (MTD) → a Relative date slicer set to This month.
    • Slicer 2 (Custom) → a normal Between slicer over Date[Date].

    3. Use Selection pane + Bookmarks:

    • Bookmark MTD: show Slicer 1, hide Slicer 2.
    • Bookmark Custom: show Slicer 2, hide Slicer 1.
    • Add a Bookmark navigator tied to the two bookmarks, or use the Mode slicer to trigger them.

    This gives exactly the behavior you want: user picks MTD → the “This Month” slicer is shown; user picks Custom → a free date-range slicer is shown.

     

    B) Single slicer (limit the effect with a measure)

    If you prefer one visible slicer, you can’t restrict its UI, but you can restrict how dates affect visuals when MTD is chosen.

    1. Same disconnected Mode table as above.

    2. Create a filter measure:

     

    Date Filter :=
    VAR ModeSel = SELECTEDVALUE ( Mode[Mode], "Custom" )
    VAR D = MAX ( 'Date'[Date] )
    VAR StartM = DATE ( YEAR ( TODAY() ), MONTH ( TODAY() ), 1 )
    RETURN
    IF (
    ModeSel = "MTD",
    IF ( D >= StartM && D <= TODAY(), 1, 0 ),
    1
    )

     

    3. Put your normal Between Date slicer on Date[Date].

    4. Add Date Filter to the Visual-level filters for all visuals that should respect the rule and set it to is 1.

     

    • When Custom is selected, visuals follow the date slicer normally (all past/future dates allowed).
    • When MTD is selected, visuals ignore selections outside the range 1st of current month → today (future and history outside MTD are effectively blocked in visuals).

     

    I hope it helps.

     

     

     

     

     

     

    • Koritala's avatar
      Koritala
      Post Patron

      Hi Ilgar,

      Thanks for your email.

      Could you please share pbxi file if you already worked on this?

      Thanks,

      Sri.

  •   

    Create a disconnected table with values MTD and Custom.

    Use a measure to set min/max dates based on the selected value, e.g.:

    DateFilter =
    IF(SELECTEDVALUE(Slicer[Type]) = "MTD",
    Dates[Date] >= STARTOFMONTH(TODAY()) && Dates[Date] <= TODAY(),
    TRUE()
    )

    Apply this as a visual-level filter on your date slicer.

     
     

    Koritala

    • Koritala's avatar
      Koritala
      Post Patron

      Hi Kedar,

      Can you share the pbxi if have for the same?

      Thanks,

      Sri

    • Koritala's avatar
      Koritala
      Post Patron

      Hi Kedhar,

      Can you share the pbxi file for your solution.

      Thanks,

      Sri

    • Koritala's avatar
      Koritala
      Post Patron

      Hi Kedhar,

      can you please share the pbxi file. I couldn't get the result.

      Thanks,

      Sri

  • Hi Koritala ,
    If you've had a chance to review Kedar_Pande  response? please let us know if you need any additional information or clarification. We're happy to assist further if needed.

     

    Thank You.

  • Hi Koritala ,

    Apologies for the delayed response.

    As of now, Power BI doesn’t natively support this requirement. However Ilgar_Zarbali  suggested workaround, I’ve implemented a solution using two slicers combined with bookmarks, and tested it with sample data.
    FYI:




     

     

    For your reference, I’ve attached a PBIX file please feel free to explore the logic and setup.

    Thanks again, Ilgar_Zarbali , for your valuable input.

    Hope this helps.

    Best regards,
    Yugandhar.

  • Hi Koritala ,
    Could you please let us know whether your issue has been resolved or if you are still encountering any difficulties? Your feedback is important to the community and may assist others with similar concerns.

    Thank You.

    • Koritala's avatar
      Koritala
      Post Patron

      Hi, issue not resolved. Based on selection, date slicers are not showing 

       

       

      • V-yubandi-msft's avatar
        V-yubandi-msft
        Community Support

        Hi Koritala ,

        Thank you for your time. Since Power BI doesn’t offer conditional slicer visibility directly, I used bookmarks and the Selection pane to toggle between two slicers.
        Here’s what I did.

        1.Created a helper table with MTD and Custom values and used it as a slicer.

        2. Slicer_Date_MTD- Set advanced filtering to show dates from the start of this month to today.

        3. Slicer_Date_Custom- left unfiltered for the full date range.

        4. Set up bookmarks

        • Bookmark_MTD shows the MTD slicer and hides the Custom slicer.
        • Bookmark_Custom shows the Custom slicer and hides the MTD slicer.

        5. Added two buttons MTD View and Custom View linked to each bookmark, so users can switch modes easily.

        FYI:

         

         

        This method uses only built in Power BI features and keeps the interface simple. I’ve attached a sample PBIX file for you to review let me know if you want any changes.

         

        Regards,
        Yugandhar.