Forum Discussion

GBB223's avatar
GBB223
Frequent Visitor
3 years ago

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

  • GBB223 , Try like

     

    Switch( True() ,

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

    "#A80000"

    )

  • GBB223's avatar
    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

  • v-luwang-msft's avatar
    v-luwang-msft
    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