Forum Discussion

morani's avatar
morani
Icon for Helper I rankHelper I
1 year ago

Change slicer fields based on a different slicer selection

HI all,

 

I have 8 measures: 

("PriorDayUnits"), ("PriorWeekUnits"), ("PriorMonthUnits"), ("PriorYearUnits") under field parameters called Comparison1

and

("PriorDayGrossSales"), ("PriorWeekGrossSales"), ("PriorMonthGrossSales"), ("PriorYearGrossSales") under field parameters called Comparison2
 
I have a field parameter slicer (that is called dynamic measure) and chooses between TotalUnits and TotalGrossSales. 
 
I want to create a second slicer that will display ("PriorDayUnits"), ("PriorWeekUnits"), ("PriorMonthUnits"), ("PriorYearUnits") if  TotalUnits is selected in slicer 1 or ("PriorDayGrossSales"), ("PriorWeekGrossSales"), ("PriorMonthGrossSales"), ("PriorYearGrossSales") if TotalGrossSales is selected in slicer 1. 
 
How do I do that? 
 
Appreciate any help

8 Replies

  • 1. Make sure your first field parameter slicer is set to single select

     

    2. delete all the other measures and create new measures that probe the SELECTEDVALUE of the first slicer and compute the required results.

    • morani's avatar
      morani
      Icon for Helper I rankHelper I

      Hi Ibendlin,

       

      Thanks for your answer. Can you please let me know how to create the new measure that probe the SELECTEDVALUE of the first slicer (TotalUnits or TotalGrossSales) and will change a second slicer to display ("PriorDayUnits"), ("PriorWeekUnits"), ("PriorMonthUnits"), ("PriorYearUnits") if  TotalUnits is selected in slicer 1 or ("PriorDayGrossSales"), ("PriorWeekGrossSales"), ("PriorMonthGrossSales"), ("PriorYearGrossSales") if TotalGrossSales is selected in slicer 1?

      • lbendlin's avatar
        lbendlin
        Icon for Super User rankSuper User

        Use SELECTEDVALUE or VALUES.  that will give you a single column table that you can use directly as a filter.

  • To achieve this functionality in Power BI, you can create a dynamic measure slicer that changes based on the selection in the first slicer. Here's how you can do it step by step:

    ---

    Step 1: Create a Field Parameter for the Second Slicer
    1. Go to the **Modeling** tab in Power BI and click on **New Parameter** > **Fields**.
    2. Create two field parameters:
    - **Comparison1**: Includes `PriorDayUnits`, `PriorWeekUnits`, `PriorMonthUnits`, `PriorYearUnits`.
    - **Comparison2**: Includes `PriorDayGrossSales`, `PriorWeekGrossSales`, `PriorMonthGrossSales`, `PriorYearGrossSales`.

    ---

    Step 2: Create a Measure to Dynamically Switch Between Field Parameters**
    Create a measure that dynamically selects the appropriate field parameter based on the selection in the first slicer (`TotalUnits` or `TotalGrossSales`).

    ```DAX
    DynamicComparison =
    SWITCH(
    SELECTEDVALUE('DynamicMeasure'[Measure]), // Replace 'DynamicMeasure' with the name of your first slicer table
    "TotalUnits", SELECTEDVALUE(Comparison1[Comparison1]),
    "TotalGrossSales", SELECTEDVALUE(Comparison2[Comparison2])
    )
    ```

    ---

    Step 3: Create the Second Slicer**
    1. Add a slicer to your report.
    2. Bind the slicer to the **DynamicComparison** measure.
    3. This slicer will now dynamically show either the `Comparison1` or `Comparison2` options based on the selection in the first slicer.

    ---

    Step 4: Configure Interactions Between Slicers**
    1. Ensure that the first slicer (`TotalUnits` or `TotalGrossSales`) is connected to the second slicer.
    2. Use the **Edit Interactions** feature in Power BI to control how the first slicer filters the second slicer.

    ---

    Step 5: Test the Dynamic Behavior**
    - Select `TotalUnits` in the first slicer, and the second slicer should display `PriorDayUnits`, `PriorWeekUnits`, `PriorMonthUnits`, `PriorYearUnits`.
    - Select `TotalGrossSales` in the first slicer, and the second slicer should display `PriorDayGrossSales`, `PriorWeekGrossSales`, `PriorMonthGrossSales`, `PriorYearGrossSales`.

     

    • morani's avatar
      morani
      Icon for Helper I rankHelper I

      Thank you so much for your thorough answer. I have a few more questions:

      1. I created the second slicer, how do I bind it to the **DynamicComparison** measure (Step3 - #2)? 

      2. How do I connect the first slicer to the second one (step4 - #1)? 

      3. Where do I find the **Edit Interactions** feature in Power BI (step4 - #2)? 

       

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

        Hi morani ,

        We haven’t heard back from you regarding our previous response and wanted to check if your issue has been resolved.

        If it has, please consider clicking “Accept Answer” and “Yes” if you found the response helpful.
        If you still have any questions or need further assistance, feel free to let us know — we're happy to help!

        Thank you!