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

How to Conditionally format text in a Card in Power BI

 

I have a Card in a power BI Dashboard that that displays roughly 6 unique text attributes depending on the input. How do I add a separate color to each attribute, for example if the card displays "apple" I want that text to be red.

9 REPLIES 9
evandrocunico
Resolver III
Resolver III

hi @Anonymous 

 

card_color = if(fieldvalue = "APPLE";"#F0F0F0";"#FFE4B5")
 
CARD - format - data label, conditional formatting - field value - select card_color
 
regards.
Anonymous
Not applicable

@evandrocunico 

Thanks for the reply, I'm farely new to Power BI but what does #F0F0F0";"#FFE4B5 mean?

it´s a color in hexadecimal.

see the colors

https://www.w3schools.com/colors/colors_picker.asp

 

colors.JPG

Anonymous
Not applicable

@evandrocunico 

I know this dosen't work but I think this is close to what I want. How could I fix this to get each text value assigned to a color.

 

 

Test Color = VAR Color = SELECTEDVALUE(Table[Color])

Return

SWITCH(TRUE(),

Color = "#FF0000", "Apple" )

 

Then Conditional format by field Value

Your first question for example if the card displays "apple" I want that text to be red

 

Measure:

 

COLOR = iF(SELECTEDVALUE(Tabela1[FRUIT])=BLANK(); "#f2f2f2";iF(SELECTEDVALUE(Tabela1[FRUIT])="Apple";"#ff0000";iF(SELECTEDVALUE(Tabela1[FRUIT])="Avocato";"#55ff22";"#ff7722")))
 
CARD - Data label - color - conditional format - field value by COLOR

 

fruits.jpg

 

Anonymous
Not applicable

Hate to bother you again but I tried the code you suggested and it pretty much worked however it displays "#ff0000" in red, and not the text like "Apple" in red.

 

What I have:

IF(SELECTEDVALUE(Colors[Color])="Apple","#ff0000",IF(SELECTEDVALUE(Colors[Color])="Watermelon","#55ff22","#ff7722"

@Anonymous can you show data table, please?

Anonymous
Not applicable

@evandrocunico 

I can't show the exact table due to confidentiality and I understand if you can't solve this because of that, but essentialy I have a table called food:

 

Food

  • Meat- Beef, Chicken, Pork
  • Fruit- Apples, Oranges, Watermelon
  • Vegtables- Carrots, Broccili, Peas

I only care about the Fruit attribute inside the food table 

@Anonymous create a measure:

 

sel_fruit = SELECTEDVALUE(Colors[Color])

show measure by card and filter option...

the result is Apple?

 

ps. excellent channel about power bi https://www.youtube.com/watch?v=zHzSBNES6jE

 

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.