Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Conditional Formatting for visuals based off a specific field value

I've created conditional formatting for text and background colour in the past, super easy.  I'm trying to set a standard for the colour that will be used for a specific set of people that are listed in a table.  I want to use this for bar charts, etc.  I tried using the conditional formatting, but I'm missing something. 

 

I created the following:

 

CSR_Color =
SWITCH(
('Cases'[Owner]),
"Eric", "1",
"Derek", "2",
"Robert", "3",
"000000"
)

 

This very nicely created a column that added the nubmer value into each entry for the CSR's.  Then I went down several paths trying to create a measure to use for the conditional formatting.  No dice.  Here was my last try:

 

CSR_Colour =
SWITCH(TRUE()
Value('Query1 - Cases'[CSR_Number]) = 1, "EE9E64",
Value('Query1 - Cases'[CSR_Number]) = 2, "95DABB",
Value('Query1 - Cases'[CSR_Number]) = 3, "4A588A",
"000000"
)
 
Any advice welcome!
  • Hi Anonymous 

    as you use a measure you need select an exactly value to compare. e.g

    CSR_Colour =
    SWITCH(MAX('Query1 - Cases'[CSR_Number]),
    1, "EE9E64",
    2, "95DABB",
    3, "4A588A",
    "000000"
    )

     

  • Anonymous's avatar
    Anonymous
    6 years ago

    After a bit more trial and error, I was able to figure out a way to use the names and not create addition columns to classify the names to a number.  This method worked perfectly to let me use the visual conditional formatting to assign the colours properly by field value for any visual that has these values. 

     

    CSR_Colour =
    SWITCH(
    True(),
    Selectedvalue('Query1 - Cases'[Owner]) = "Eric", "#EE9E64",
    Selectedvalue('Query1 - Cases'[Owner]) = "Derek", "#95DABB",
    Selectedvalue('Query1 - Cases'[Owner]) = "Robert", "#4A588A",
    Selectedvalue('Query1 - Cases'[Owner]) = "Christine", "#73B761",
    Selectedvalue('Query1 - Cases'[Owner]) = "Jessica", "#75754f",
    "#000000"
    )

2 Replies

  • az38's avatar
    az38
    Community Champion

    Hi Anonymous 

    as you use a measure you need select an exactly value to compare. e.g

    CSR_Colour =
    SWITCH(MAX('Query1 - Cases'[CSR_Number]),
    1, "EE9E64",
    2, "95DABB",
    3, "4A588A",
    "000000"
    )

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    After a bit more trial and error, I was able to figure out a way to use the names and not create addition columns to classify the names to a number.  This method worked perfectly to let me use the visual conditional formatting to assign the colours properly by field value for any visual that has these values. 

     

    CSR_Colour =
    SWITCH(
    True(),
    Selectedvalue('Query1 - Cases'[Owner]) = "Eric", "#EE9E64",
    Selectedvalue('Query1 - Cases'[Owner]) = "Derek", "#95DABB",
    Selectedvalue('Query1 - Cases'[Owner]) = "Robert", "#4A588A",
    Selectedvalue('Query1 - Cases'[Owner]) = "Christine", "#73B761",
    Selectedvalue('Query1 - Cases'[Owner]) = "Jessica", "#75754f",
    "#000000"
    )