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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
DaniLP
New Member

Conditional format Card value based on the result on another Card

Hi all, 

 

I am unsure if its possible, but i tried looking around and can't seem to find a way. 

Im fairly new using and learning on my own pace PowerBI and had to say this so you know my level... quite basic.

 

I would like to know if its possible to conditional format color of a Card value, based on the result of another card.

 

I have some data, and basically it has some items with a column with dates, and column with its status.

In a card1, i display the sum of items up to Today. 

And in another card2, i have the sum of items up to today, that are still pending status.

 

And i would like to color code the result of the card2 , depending on the card1 result. 

 

So if i am having 10 items until today, but only 2 complete, means card1 will show 10 and card2 will display 8 items. 

Cant use threshold since each day, the value will be different, if that makes sense...

So would like to be able to display red/green depending if the value is below or (for whatever reason higher) than the card1.

 

I hope i managed to explain the idea and that there is someone able to help 🙂

 

Thanks in advance!  

1 ACCEPTED SOLUTION

Then you will need to create a measure with those filters. 

 

Create the ones bellow

 

# Items = 
    --Bellow put the column refering to the items being summed
    SUM('table'[column])


Card 1 Measure = 
    CALCULATE(
        [# Items],
        DATESINPERIOD('Date'[Date], TODAY() , -1000 , DAY )
    )


Card 2 Measure =
    CALCULATE(
        [# Items],
        status[status] in {"Not Started","On Hold","In progress"}
    )

Conditional formating measure = 
VAR _carddiff = [Card 2 Measure] - [Card 1 Measure]

RETURN
IF( _carddiff <> 0, 1, 0)
    

 

View solution in original post

8 REPLIES 8
jcalheir
Solution Supplier
Solution Supplier

Hi,

 

Yes, you can use conditional formating on a card background based on any measure you want. Just click on the fx icon shown bellow. Then add create the measure you want  to be analyzed and add a rule to it.

 

jcalheir_0-1664361638581.png

 

In your example, maybe create a measure like this:

Conditional formating measure = 
VAR _carddiff = [Measure Card 1] - [Measure Card 2]

RETURN
IF( _carddiff <> 0, 1, 0)
    


This will return 1 if the card measures have diferent values

 

Then add a rule the if the value is 1 has some colour

 

jcalheir_1-1664362159235.png

 

 

Hope it helps.

 

Kind regards,
José
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

Hi, thanks for the reply.
I am unsure in how to make the quick measure with what appears in the Card1/2.

Card1 value is basically the total, but to the card i apply some filters in order to obtain the result. 

So card1 would be total items, up to today.

and card2 would be total items up to today, not complete.

But, as mentioned, both Card1 and 2 are showing values based on filteres applied to the visual. 

 

Is your method requiring that the calculations are made without filters in the visual? or how i can add the card code so i can complete the formula you suggested for the measure? 

 

thanks in advance!

 

Yes, in this case you will need to pass the filters to the measures.

 

Could you share your pbix file so i can provide and example?

Can't share the file, but hopefully screens below help:

Card1 filters:

DaniLP_0-1664370134319.png

Card2 filters:

same as above+

DaniLP_1-1664370192755.png

DaniLP_2-1664370357321.png

Card1 is displaying a 5, and Card2 is displaying a 2 in this case.

 

is this enough? thanks 🙂 

Then you will need to create a measure with those filters. 

 

Create the ones bellow

 

# Items = 
    --Bellow put the column refering to the items being summed
    SUM('table'[column])


Card 1 Measure = 
    CALCULATE(
        [# Items],
        DATESINPERIOD('Date'[Date], TODAY() , -1000 , DAY )
    )


Card 2 Measure =
    CALCULATE(
        [# Items],
        status[status] in {"Not Started","On Hold","In progress"}
    )

Conditional formating measure = 
VAR _carddiff = [Card 2 Measure] - [Card 1 Measure]

RETURN
IF( _carddiff <> 0, 1, 0)
    

 

thanks, i try replicate the measure, but unsure what part of it makes me get error:

DaniLP_1-1664372638611.png

 

Code below (taken from yours, and adjusted to my table names):

 

FDSColor = 
    --Bellow put the column refering to the items being summed
    SUM('RICEFW'[FDS Status])


Card 1 Measure = 
    CALCULATE(
        [FDSColor],
        DATESINPERIOD('Date'[Date], TODAY() , -1000 , DAY )
    )


Card 2 Measure =
    CALCULATE(
        [FDSColor],
        RICEFW[FDS Status] in {"Not Started","On Hold","In progress"}
    )

Conditional formating measure = 
VAR _carddiff = [Card 2 Measure] - [Card 1 Measure]

RETURN
IF( _carddiff <> 0, 1, 0)

 

 Is it Card 2 Status part? unsure if i messed up the translation into my table/column name.

 

I call measure FDS Color because i will have to do this same measure 5x more times for other 5 different types. so wanted to have some easy time to identify each.

 

Thanks in advance!

 

 

 

Hi

 

I guess you posting all that code in the same measure.

 

You need to create each measure separadly in order to make it work.

 

If you want to learn more about measures in power BI you can watch the video bellow

https://www.youtube.com/watch?v=9VtaOAM2oOM&ab_channel=EnterpriseDNA

 

 

Ill have a look, thanks for your help! 🙂 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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