Forum Discussion

Mokegubshook's avatar
Mokegubshook
Icon for Helper I rankHelper I
1 year ago
Solved

Slicer to show date include weekend or exclude weekend

Hi, I want to have a slicer for users to select either "Include weekend" or "Exclude weekend". My visual is metrix which have date as column. If user select Include weekend - I would like to show all date. If user select Exclude weekend - I would like to show date except weekend.

  • Hey Mokegubshook,

    Here's a solution to create a weekend include/exclude slicer for your date-based matrix visual:

    Solution Steps:

    1. Create the Slicer Table

    • Create a new table with two values: "Include Weekend" and "Exclude Weekend"
    • Use DAX: Weekend Filter = DATATABLE("Filter Type", STRING, {{"Include Weekend"}, {"Exclude Weekend"}})

    2. Build the Date Filter Measure

    • Create a measure to identify weekend dates and apply filtering logic
    • Use WEEKDAY function to detect Saturday (7) and Sunday (1)

    Date Filter Measure =
    VAR SelectedFilter = SELECTEDVALUE('Weekend Filter'[Filter Type], "Include Weekend")
    VAR IsWeekend = WEEKDAY(MAX('Date'[Date]), 2) IN {6, 7}
    RETURN
    IF(
    SelectedFilter = "Exclude Weekend" && IsWeekend,
    BLANK(),
    1
    )

    3. Apply Filter to Matrix

    • Add this measure to the Filters pane of your matrix visual
    • Set filter condition to "is not blank"
    • This will hide weekend dates when "Exclude Weekend" is selected

    4. Configure the Slicer

    • Add the Weekend Filter table as a slicer
    • Set default selection to "Include Weekend"
    • Position slicer above your matrix for easy access

    5. Testing

    • Verify that selecting "Include Weekend" shows all dates
    • Confirm "Exclude Weekend" hides Saturday and Sunday entries
    • Check that weekday dates remain visible in both scenarios

    This approach gives users dynamic control over weekend visibility without modifying your underlying date table or relationships.

     

    Fixed? ✓ Mark it • Share it • Help others!


    Best Regards,
    Jainesh Poojara | Power BI Developer

  • Hi Mokegubshook 

     

    Create a new table using Enter Data and add your two options. Call the column Slicer choice.
    Add a measure:

    Filter Weekdays =
    If(
     Weekday(selectedvalue('Data table'[SaleDate]),2) IN {6,7}
    && SelectedValue('Slicer table'[Slicer choice]) = "Exclude weekend"
    ,Blank()

    ,1
    )

     

    Add this measure into the filter pane under Filters on this visual then filter to 1.

    File attached 🙂

2 Replies

  • jaineshp's avatar
    jaineshp
    Icon for Memorable Member rankMemorable Member

    Hey Mokegubshook,

    Here's a solution to create a weekend include/exclude slicer for your date-based matrix visual:

    Solution Steps:

    1. Create the Slicer Table

    • Create a new table with two values: "Include Weekend" and "Exclude Weekend"
    • Use DAX: Weekend Filter = DATATABLE("Filter Type", STRING, {{"Include Weekend"}, {"Exclude Weekend"}})

    2. Build the Date Filter Measure

    • Create a measure to identify weekend dates and apply filtering logic
    • Use WEEKDAY function to detect Saturday (7) and Sunday (1)

    Date Filter Measure =
    VAR SelectedFilter = SELECTEDVALUE('Weekend Filter'[Filter Type], "Include Weekend")
    VAR IsWeekend = WEEKDAY(MAX('Date'[Date]), 2) IN {6, 7}
    RETURN
    IF(
    SelectedFilter = "Exclude Weekend" && IsWeekend,
    BLANK(),
    1
    )

    3. Apply Filter to Matrix

    • Add this measure to the Filters pane of your matrix visual
    • Set filter condition to "is not blank"
    • This will hide weekend dates when "Exclude Weekend" is selected

    4. Configure the Slicer

    • Add the Weekend Filter table as a slicer
    • Set default selection to "Include Weekend"
    • Position slicer above your matrix for easy access

    5. Testing

    • Verify that selecting "Include Weekend" shows all dates
    • Confirm "Exclude Weekend" hides Saturday and Sunday entries
    • Check that weekday dates remain visible in both scenarios

    This approach gives users dynamic control over weekend visibility without modifying your underlying date table or relationships.

     

    Fixed? ✓ Mark it • Share it • Help others!


    Best Regards,
    Jainesh Poojara | Power BI Developer

  • Hi Mokegubshook 

     

    Create a new table using Enter Data and add your two options. Call the column Slicer choice.
    Add a measure:

    Filter Weekdays =
    If(
     Weekday(selectedvalue('Data table'[SaleDate]),2) IN {6,7}
    && SelectedValue('Slicer table'[Slicer choice]) = "Exclude weekend"
    ,Blank()

    ,1
    )

     

    Add this measure into the filter pane under Filters on this visual then filter to 1.

    File attached 🙂