Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
GBB223
Frequent Visitor

Change color for each selected data

Hi, I currently have codes that change the color of selected data on a scatter plot, but I'm trying to have different color for each selection. The code is below, 

 

DataToHighlight =
Var _SelectedProduct =
    VALUES(SelectedProduct[Product Name])
Var _DataToHighlight =
    SELECTEDVALUE('Data'[Product Name])
Var _Filtered =
    ISFILTERED(SelectedProduct[Product Name])
Var _Result =
SWITCH(
    TRUE(),
    NOT(_Filtered), "#A80000",
    _DataToHighlight IN _SelectedProduct &&
    _Filtered, "#A80000", "118DFF"
)
RETURN _Result
 
How could I change the code so that selected data have different color and be able to distinguish between the selected data? Thank you. 
 
 
3 REPLIES 3
v-luwang-msft
Community Support
Community Support

Hi @GBB223 ,

Has your problem been solved, if so, please consider Accept a correct reply as the solution or share your own solution to help others find it.

Best Regards
Lucien

GBB223
Frequent Visitor

@amitchandak Thank you for your response. Tried it but it still only shows two color for multiple selections. I would like to have something like, SelectedProduct A = red, SelectedProduct B = green, SelectedProduct C = yellow, ...., rest of the product = blue

amitchandak
Super User
Super User

@GBB223 , Try like

 

Switch( True() ,

max('Data'[Product Name]) in VALUES(SelectedProduct[Product Name]) , "118DFF",

"#A80000"

)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (13,137)