Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Custom Slicer on INT value

Please help me create a custom table slicer with the criteria below

 

Custom Slicer Table = 

Number of Days <= 15
Number of Days >= 15 & Number of Days =< 30
Number of Days = All Number of Days 

 

Actual Table

Group_IDNumber of Days
T-100028
T-100123
T-100222
T-100320
T-100419
T-100514
T-100619
T-100736
T-100821
T-100914
T-101014
  • Hi Anonymous , You can create a calculated column with below dax and pull it inside a slicer. Enable select all option for the slicer to select all the days

     

    Range = SWITCH(TRUE(),
    'Table'[Number of Days] <= 15, "<= 15 Days",
    'Table'[Number of Days] > 15 && 'Table'[Number of Days] <= 30,"> 15 and <= 30 Days",">30 Days")

     

     

    Did I answer your question ? If yes, please mark my post as a solution

     

    Thanks,

    Jai

4 Replies

  • Hi Anonymous , You can create a calculated column with below dax and pull it inside a slicer. Enable select all option for the slicer to select all the days

     

    Range = SWITCH(TRUE(),
    'Table'[Number of Days] <= 15, "<= 15 Days",
    'Table'[Number of Days] > 15 && 'Table'[Number of Days] <= 30,"> 15 and <= 30 Days",">30 Days")

     

     

    Did I answer your question ? If yes, please mark my post as a solution

     

    Thanks,

    Jai

    • Anonymous's avatar
      Anonymous
      Not applicable

      How to set the order of the Range?

       

      1. All

      2. <= 15 Days
      3. > 15 and <= 30 Days",">30 Days

  • Anonymous 

    Create a New Calculated Table for the Slicer

    Custom Slicer Table = 
    DATATABLE(
    "Range", STRING,
    {
    {"Number of Days <= 15"},
    {"Number of Days >= 15 & Number of Days <= 30"},
    {"All Number of Days"}
    }
    )

    Create a Measure for Filtering

    Filtered Measure = 
    VAR SelectedRange = SELECTEDVALUE('Custom Slicer Table'[Range])
    RETURN
    SWITCH(
    TRUE(),
    SelectedRange = "Number of Days <= 15", IF(MAX('Actual Table'[Number of Days]) <= 15, 1, 0),
    SelectedRange = "Number of Days >= 15 & Number of Days <= 30", IF(MAX('Actual Table'[Number of Days]) >= 15 && MAX('Actual Table'[Number of Days]) <= 30, 1, 0),
    SelectedRange = "All Number of Days", 1,
    0
    )

    Add the Custom Slicer Table to your report and use it as a slicer.
    Add the Actual Table to your visuals (e.g., table or chart).
    Go to the Filters pane for the visual and apply the Filtered Measure as a filter, setting the value to 1.

     

    💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
    Cheers,
    Kedar
    Connect on LinkedIn

    • Anonymous's avatar
      Anonymous
      Not applicable
      I am trying your version, and getting error "The MAX function in DAX only accepts a column reference as an argument"
       
      How to fix?


      Filtered
      Measure =
      VAR SelectedRange = SELECTEDVALUE('Custom Slicer Table'[Range])
      RETURN
      SWITCH(
      TRUE(),
      SelectedRange = "Number of Days <= 15", IF(MAX('Invoices'[Number of Days before invoice received by AP]) <= 15, 1, 0),
      SelectedRange = "Number of Days >= 15 & Number of Days <= 30", IF(MAX('Invoices'[Number of Days before invoice received by AP]) >= 15 &&
      MAX('Invoices'[Number of Days before invoice received by AP]) <= 30, 1, 0),
      SelectedRange = "All Number of Days", 1,
      0
      )