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
Ayappan
Helper III
Helper III

Card Background color change on condition

Hi ,

     I want to update my card color based on the total value recived .

     Example : i have Total 22 students 

                      if 22 also passed that is 100% in maths means it  should be in green 

                      if 11 passed 50 % only so it should be in orange 

                      if only 5 pass it is less that 40 % it should show red 

Thanks for your help

9 REPLIES 9
v-yanjiang-msft
Community Support
Community Support

Hi @Ayappan ,

Has your problem been solved by @Samarth_18 's final solution, if yes, please consider accept it as the solution to help the other members find it more quickly.

Best Regards,
Community Support Team _ kalyj

Samarth_18
Community Champion
Community Champion

HI @Ayappan ,

 

Create a measure like below:-

Measure = 
var _total = COUNTROWS('Table')
var _passed = COUNTROWS(FILTER('Table','Table'[Result] = "PASS"))
return (_passed/_total)

 

Create a another measure with below code for conditional formatiing

Measure 2 = 
SWITCH(TRUE(),
[Measure] = 0.5,"Orange",
[Measure] < 0.5,"Red",
[Measure] = 1,"Green")

Refere below file for reference:-

https://we.tl/t-wu1PQjkNSA

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hi Samarath,

   This is wokking but can we simplify into 1 measure. Is it posible..

Becasue for other subjects also i have to do then each subject will have 2 measures

@Ayappan , Try this:-

Measure =
VAR _total =
    COUNTROWS ( 'Table' )
VAR _passed =
    COUNTROWS ( FILTER ( 'Table', 'Table'[Result] = "PASS" ) )
VAR result = ( _passed / _total )
RETURN
    SWITCH (
        TRUE (),
        result = 0.5, "Orange",
        result < 0.5, "Red",
        result = 1, "Green"
    )

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

visheshjain
Impactful Individual
Impactful Individual

Hi @Ayappan ,

 

From the conditional formatting pane shown in the picture previously, you can change the number to be a percentage and specify the values.

If you want to use a single measure, then you can use the solution provided by @Samarth_18 and convert the result of measure 1 into a variable and use measure 2 after the 'return' statement.

 

Hope this helps.

Thank you,

Vishesh Jain

Did I answer your question?
If yes, then please mark my post as a solution!

Thank you,
Vishesh Jain

Proud to be a Super User!



KerKol
Power Participant
Power Participant

In the formatting pane...

 

KerKol_0-1645080811444.png

 

Create a measure like...

 

KPI =
Var KPIs = IF([Percentage]>0.83, IF([Percentage]>0.5, 2, 1)
Return
KPIs

 

KerKol_3-1645081308782.png

 

 

KerKol_0-1645081531345.png

 

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks for your response .

  But this is based on number i need in percentage ..

KerKol
Power Participant
Power Participant

KPI =
Var Percentage = DIVIDE([Result],[Total])
Var KPIs = IF([Percentage]>0.83, IF([Percentage]>0.5, 2, 1)
Return
KPIs




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




PijushRoy
Super User
Super User

Hi @Ayappan 

Please share sample data or sample pbix file. You can paste excel format data.

Thanks




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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