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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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!
2 ACCEPTED SOLUTIONS
az38
Community Champion
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"
)

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

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"
)

View solution in original post

2 REPLIES 2
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"
)
az38
Community Champion
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"
)

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.