Forum Discussion

Szokens's avatar
Szokens
Icon for Helper II rankHelper II
1 year ago
Solved

Measure Slicer doesn't work on my visuals

Hello Everyone,

I started new topic to not create a mess. So I had my solution working with all calculations described in this post

https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-table-column-values-changes-on-slicer-selection/m-p/4749881#M181871

Now I would like to enhance my report by additional feature available for user. I would like user to apply additional slicer which will "Include" or "Exclude" weekends in visual results. 

I have created following disconnected table:

Weekend_Toggle_Table =
DATATABLE(
    "Toggle_Weekends",
    STRING,
    "Order",INTEGER,
{
    {"Exclude",1},
    {"Include",2}
})
in my semantic model I have also connected "dmn_date" table with field "dmn_date[is_weekday]" having "Y" or "N" values.
Then I created this measure:
toogle_weekends_filter =
VAR SelectedToggle = SELECTEDVALUE(Weekend_Toggle_Table[Toggle_Weekends])
VAR Isweekday = IF(MAX(dmn_date[is_weekday])="Y",1,0)
RETURN
SWITCH(TRUE(),
    SelectedToggle="Exclude" && Isweekday=1,1,
    SelectedToggle="Include",1,
    0)
When I apply above measure to visual filters pane of randomly created table visual (screenshot below) and set value to "1", it works fine, however when I do the same for my visual with calcs described in post mentioned above, visual doesn't react.

 

I don't wan't to give user ability to slice by dmn_date[is_weekday] as "Y"/"N" or all, this is why I need to invent "Include" / "Exclude" weekends slicer.

  • I believe you're overthinking the toggle. All you need to do is make a new conditional column based on your is_weekday. If Y then include if N then exclude. Toss that in a slicer and you're done!

9 Replies

  • Syk's avatar
    Syk
    Icon for Resident Rockstar rankResident Rockstar

    I believe you're overthinking the toggle. All you need to do is make a new conditional column based on your is_weekday. If Y then include if N then exclude. Toss that in a slicer and you're done!

    • Szokens's avatar
      Szokens
      Icon for Helper II rankHelper II

      so this will give me two slicer options Mon-Fri (for "Include") and only weekends (for "Exclude"). I would need to make slicer multiselect and enable "all". Then sure it is fine.

      I wonder however if is it possible to make it the way "Include" - whole week Mon-Sun, "Exclude" - without weekends, Mon-Fri and have only single selection slicer.

    • Szokens's avatar
      Szokens
      Icon for Helper II rankHelper II

      finally I have used Syk  approach which is simpliest and fast. 

  • v-sgandrathi's avatar
    v-sgandrathi
    Icon for Community Support rankCommunity Support

    Hi Szokens,

     

    you want to give users a single slicer where:

    • Include → Shows all days (Mon-Sun)
    • Exclude → Shows only weekdays (Mon-Fri)

    You don’t want to expose the is_weekday column directly to users, which makes sense.

    The issue is happening your measure works fine when you test it in a simple table that shows dates and weekdays.
    But when you apply the same logic in visuals where you have pre-calculated logic or summary calculations like in your previous post, the dmn_date[is_weekday] context may not be properly available.
    That’s why the toggle is not reacting properly in those visuals.

    Please find the attached file for your reference.
    Hope this helps if you have any queries we are  happy to assist you further.


    Regards,
    Sahasra.

    • Szokens's avatar
      Szokens
      Icon for Helper II rankHelper II

      is it possible to make it working as expected in Barchart or Linechart? I see in the simple table it is ok but when trying to apply on mentioned visuals I don't get how to customize them to make it working.

      • v-sgandrathi's avatar
        v-sgandrathi
        Icon for Community Support rankCommunity Support

        Hi Szokens,

         

        Yes, it is certainly possible to have your weekend toggle slicer function within visuals such as bar charts and line charts. However, it is important to ensure that the filtering logic is incorporated directly into the DAX measures used in these visuals.

        While your current method is effective in table visuals due to the row context, bar and line charts rely on aggregated data and may not respond to visual-level filters in the same way. Therefore, embedding the logic within the measure calculation is essential for consistent results.

         

        Total_Value_With_Toggle :=
        
        VAR SelectedToggle = SELECTEDVALUE(Weekend_Toggle_Table[Toggle_Weekends], "Include")
        
        RETURN
        
        CALCULATE(
        
            [Your_Base_Measure], -- Replace with your actual base measure (e.g., [Total Sales])
        
            FILTER(
        
                dmn_date,
        
                SWITCH(
        
                    TRUE(),
        
                    SelectedToggle = "Exclude" && dmn_date[is_weekday] = "Y", TRUE(),
        
                    SelectedToggle = "Include", TRUE(),
        
                    FALSE()
        
                )))

        Use this measure in your bar or line chart.

        Thank you.