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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors