Forum Discussion

Karie2413's avatar
Karie2413
New Member
2 years ago

Dynamic Bar Chart Coloring: Adjusting Color Based on Slider

I want to dynamically change the color of individual bars on a bar chart based on the survey selected in a slider. However, I'm encountering difficulties as the data is organized in different columns of the table, leading to all bars changing colors instead of just the selected one.

My data structure is as follows:

The dashboard looks as follows

Any help or suggestions would be greatly appreciated. Thank you!

 

4 Replies

  • PijushRoy's avatar
    PijushRoy
    Community Champion

    Hi Karie2413 

    Please create a measure

     

    Color = 
    SWITCH(
    TRUE(),
    Selectedvalue(Table[Survey])="Survey 1","Green",
    Selectedvalue(Table[Survey])="Survey 1","Yellow",
    "Red")

     

     

    In BAR color section, use Fx option and FieldValue from dropdown and use the Measure 
    Example only


    Let me know if that works for you


    If your requirement is solved, please mark THIS ANSWER as SOLUTION ✔️ and help other users find the solution quickly. Please hit the Thumbs Up 👍 button if this comment helps you.

    Thanks
    Pijush
    Linkedin

    • Karie2413's avatar
      Karie2413
      New Member

      Thank you for responding so quickly. However, implementing your code results in all the bars changing colors, whereas my intention is to have only the selected bars change color. To clarify, when I select "Survey 1" on the slider, I expect only the bars corresponding to "good_price" and "good_quality" to change color, while the others remain unaffected.

      • PijushRoy's avatar
        PijushRoy
        Community Champion

        Hi Karie2413 

        Please share complete requirement,
        If Survey 1 what is the color for good_price and good_quality and rest of item
        If Survey 2 what is the color for good_price and good_quality and rest of item