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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Conditional colour format on data card

Hi there

 

I have two data cards - one with an average pass ratio, and the other with the pass ratio which changes when you select different slicers. So you can compare the pass ratio alongside the average, to see if you've done better or worse. Lovely.

I want the colour of the pass ratio to be green if it's higher than the average, and red if it's lower. 


I'm not sure how to do this. Help!

1 ACCEPTED SOLUTION
edhans
Super User
Super User

Hi @Anonymous, this is a multistep process.

  1. Compute a measure that returns your color selections. I used this:

 

 

Vs Average = 
VAR varCurrentValue = SELECTEDVALUE('Table'[Value],0)
VAR varAverage = [Average Value]
RETURN
    SWITCH(
        TRUE(),
        varCurrentValue > varAverage, "Green",
        varCurrentValue = varAverage, "Black",
        varCurrentValue < varAverage, "Red"
    )

 

 

    1. So if the current selected value (I used a slicer to select a value) is greater than the Average Value measure, return Green, if equal, black, if below, red. The average value measure is:

 

 

Average Value = 
CALCULATE(
    AVERAGE('Table'[Value]),
    REMOVEFILTERS('Table'[Category])
)

 

 

  1. Then on the original card, select the label property and change the color from what is probably black to use the fx button conditional format:
    1. edhans_0-1597870389358.png

       

    2. Then select the Field Value setting, and select the measure you used -  Vs Average in my case.
    3. edhans_1-1597870418913.png

       

edhans_2-1597870454848.png

 

You can see my PBIX here if you want to play with it a bit. You can get rid of my green/red/black text and use hex codes as long as they are in the format "#000000" with the # sign to tweak those colors.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@Anonymous , You can create a color measure and use that under conditional formatting with field option.

example

Color sales = if(AVERAGE(Sales[Sales Amount])<170,"green","red")
Color Year = if(FIRSTNONBLANK(Table[Year],2014) <=2016,"lightgreen",if(FIRSTNONBLANK(Table[Year],2014)>2018,"red","yellow"))

 

Color Field - Color Measure - Conditional formatting
https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

icon based
https://exceleratorbi.com.au/conditional-formatting-using-icons-in-power-bi/
https://community.powerbi.com/t5/Desktop/FORMAT-icon-set-for-use-in-a-data-card/td-p/811692

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

You also could reference this thread that I answered to have a try.

https://community.powerbi.com/t5/Desktop/Formatting-Arrow-in-Card/td-p/931483

 

Please reference the document to learn more about conditional formatting.

Color based on a calculation 

 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
edhans
Super User
Super User

Hi @Anonymous, this is a multistep process.

  1. Compute a measure that returns your color selections. I used this:

 

 

Vs Average = 
VAR varCurrentValue = SELECTEDVALUE('Table'[Value],0)
VAR varAverage = [Average Value]
RETURN
    SWITCH(
        TRUE(),
        varCurrentValue > varAverage, "Green",
        varCurrentValue = varAverage, "Black",
        varCurrentValue < varAverage, "Red"
    )

 

 

    1. So if the current selected value (I used a slicer to select a value) is greater than the Average Value measure, return Green, if equal, black, if below, red. The average value measure is:

 

 

Average Value = 
CALCULATE(
    AVERAGE('Table'[Value]),
    REMOVEFILTERS('Table'[Category])
)

 

 

  1. Then on the original card, select the label property and change the color from what is probably black to use the fx button conditional format:
    1. edhans_0-1597870389358.png

       

    2. Then select the Field Value setting, and select the measure you used -  Vs Average in my case.
    3. edhans_1-1597870418913.png

       

edhans_2-1597870454848.png

 

You can see my PBIX here if you want to play with it a bit. You can get rid of my green/red/black text and use hex codes as long as they are in the format "#000000" with the # sign to tweak those colors.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

HI @Anonymous 

 

You can conditionaly format the background of the card.

pranit828_0-1597870478951.png

and the data label of the card.

pranit828_1-1597870506501.png

pranit828_2-1597870551753.png

 

Anonymous
Not applicable

Yes @Anonymous I know you can conditionally format the card, my question is, what measure do I use to say if [current value] is greater than [average value] then 'green' else if [current value] is less than [average value] then 'red' else 'black'

@Anonymous - I included a measure that shows this:

Vs Average = 
VAR varCurrentValue = SELECTEDVALUE('Table'[Value],0)
VAR varAverage = [Average Value]
RETURN
    SWITCH(
        TRUE(),
        varCurrentValue > varAverage, "Green",
        varCurrentValue = varAverage, "Black",
        varCurrentValue < varAverage, "Red"
    )

It is not the only way, but a way. Did you download my PBIX file and see how the entire process worked? If it doesn't do what you want, can you be more specific?



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

hi @Anonymous 

 

I would create a measure which return 1 or 0 and -1 for us, and use it to conditionally format.

Helpful resources

Announcements
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 Kudoed Authors