Forum Discussion

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

Change color DAX or something

I have the following scatterplot and want to change the color of the markers for the groups selected by the slicer.
Is it possible to achieve this using the DAX formula or other functions?

1. When group A is selected, the corresponding items will be red, and items in groups B and C will be gray.
2. When group B is selected, the corresponding item will be yellow, and the items corresponding to groups A and C will be gray
3. When group C is selected, the corresponding item will be blue and the items corresponding to groups A and B will be gray.

 

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi nanacobsbs,

     

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,
    Vinay Pabbu

5 Replies

  • HI nanacobsbs ,

    Yes, you can achieve this using DAX in Power BI by creating a Measure for the color logic and applying it to the scatterplot’s conditional formatting.

     

    Steps to Implement:
    Create a Measure to determine the color dynamically based on the slicer selection.

    Apply this Measure to the scatterplot's marker color conditional formatting.

    DAX Measure for Dynamic Coloring

    ColorMeasure =
    VAR SelectedGroup = SELECTEDVALUE('GroupTable'[Group]) -- Gets the selected group from the slicer
    VAR CurrentGroup = MAX('DataTable'[Group]) -- Retrieves the group for the current row in the visualization
    
    RETURN
    SWITCH(
    TRUE(),
    SelectedGroup = "A" && CurrentGroup = "A", "Red",
    SelectedGroup = "A" && CurrentGroup <> "A", "Gray",
    SelectedGroup = "B" && CurrentGroup = "B", "Yellow",
    SelectedGroup = "B" && CurrentGroup <> "B", "Gray",
    SelectedGroup = "C" && CurrentGroup = "C", "Blue",
    SelectedGroup = "C" && CurrentGroup <> "C", "Gray",
    "Gray" -- Default color (when nothing is selected)
    )


    How to Apply This in Power BI Scatterplot:
    Select the Scatterplot Visualization

    Go to the Format Pane → Shapes

    Expand "Markers" → fx (Conditional Formatting for Marker Color)

    Choose "Field Value"

    Select the "ColorMeasure" DAX Measure

    Click OK

     

    Please mark this post as solution if it helps you. Appreciate Kudos.

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

      Thank you for your reply.
      I tried to create the measure above, but it doesn't  work as bellow.



      I would like to have Group A checked with the slicer but still have Group B and C markers visible and their colors grayed out.
      Is it possible to achieve such a thing?



      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi nanacobsbs,

         

        When you select Group A in the slicer, Power BI filters the visual to show only Group A, which is why B and C markers disappear — not just their colors.

         

        To fix this, you need to disconnect the slicer from filtering the scatter plot, and instead only use the slicer for the color logic.

         

        Regards,

        Vinay Pabbu

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi nanacobsbs,

     

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,
    Vinay Pabbu