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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
h4_dkj
Helper I
Helper I

Conditiional formatting on calculated columns

Hi

 

I have created two different meassuers

#1

KPI_3_1_Budget =
if('BUDGET_COMMITMENTS (2)'[ACCOUNT] >= 3000,
f('BUDGET_COMMITMENTS (2)'[ACCOUNT] <= 7999,
if('BUDGET_COMMITMENTS (2)'[CODE_B] = 430,
IF(
'BUDGET_COMMITMENTS (2)'[BUDGET_VERSION]="B",
IF(
'BUDGET_COMMITMENTS (2)'[SIMULATION_VOUCHER]="FALSE",
'BUDGET_COMMITMENTS (2)'[BUDGET_AMOUNT],0)))))

 

#2

KPI_3_4_Real =
if('BUDGET_COMMITMENTS (2)'[ACCOUNT] >= 3000,
if('BUDGET_COMMITMENTS (2)'[ACCOUNT] <= 7999,
if('BUDGET_COMMITMENTS (2)'[CODE_B] = 430,
'BUDGET_COMMITMENTS (2)'[AMOUNT_BALANCE],
0)))

 

This all works just fine and I want my visual to look like the on below

 

MonthRealBudget
1155 000150 000
2147 000150 000
3162 000157 000

 

I have tried using conditional formatting but I cannot get it right.  Any comments or ideas?

17 REPLIES 17
v-yalanwu-msft
Community Support
Community Support

Hi, @h4_dkj ;

Try to create a measure :

condition = IF([4_Real]<[1_Budget],"red","green")

then set conditional format.

vyalanwumsft_0-1626687990301.pngvyalanwumsft_1-1626688039122.png

The final output is shown below:

vyalanwumsft_2-1626688057892.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for your input, that allmost solves it but when I implement it it is either all green or all read.

And I cannot figure out why 🙂

Hi, @h4_dkj ;

Oh, Too little information is provided, it is difficult to know the reasons for all green or all red, can you share more information or simple pbix example after removing sensitive information?

 

Hi

 

Abit difficult to reduce it to non-sensitive.

But I had a look at my dataset.

Using that condition formula I end up flagging every row in my dataset with either green or red flag. 

The dataset I work with look something like this:

 

PeriodkeyAccountCostBudgetrowid
20214300005001
20214300106502
20215300005503
20215300106654
20214300045005
20214300165206
20215300055007
20215300166308
2021650000-1259
2021650010-20010
202165000-126011
202165001-198012

 

The trouble now is that the algined data for 20214 account 3000, row 1 and 5 would be red as we have earned less then the budget. To complicate it even further

The algined data for 20216 account 5000, row 9 & 11 would the tell us the we have earned more then budget and hence should be green.

So in order for my condition to work it would need to evalute the sum in my visual rather then each post seperately.

 

Hi, @h4_dkj ;

According to your simple data, you could create a measure as follows:

condition =
IF (
    SUMX (
        FILTER (
            ALL ( 'Table' ),
            [Account] = MAX ( [Account] )
                && [Periodkey] = MAX ( [Periodkey] )
        ),
        ABS ( [Cost] ) - ABS ( [Budget] )
    ) < 0,
    "red",
    "green")

In addition, ABS() can be deleted according to your needs. The final output is shown below:

vyalanwumsft_0-1626852446810.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi

 

I just tried to create the following measure

 

KPI_Consition =
IF (
SUMX (
FILTER (
ALL ( 'BUDGET_COMMITMENTS (2)' ) [ACCOUNT] = MAX ( [ACCOUNT] ) && ( [PeriodKey] ) = MAX ( [PeriodKey] )
),
ABS ( 'BUDGET_COMMITMENTS (2)'[KPI_1_1_Virkelig] ) - ABS ( 'BUDGET_COMMITMENTS (2)'[KPI_1_1_Budsjett] )
) < 0,
"red",
"green")
 
It fails saying:
 
Syntax for [ACCOUNT] is wrong. (DAX(IF ( SUMX ( FILTER ( ALL ( 'BUDGET_COMMITMENTS (2)' ) [ACCOUNT] = MAX ( [ACCOUNT] ) && ( [PeriodKey] ) = MAX ( [PeriodKey] ) ), ABS ( 'BUDGET_COMMITMENTS (2)'[KPI_1_1_Virkelig] ) - ABS ( 'BUDGET_COMMITMENTS (2)'[KPI_1_1_Budsjett] ) ) < 0, "red", "green"))).

Hi, @h4_dkj ;

There is one missing "," symbol is shown below:

vyalanwumsft_0-1626858269872.png

KPI_Consition =
IF (
    SUMX (
        FILTER (
            ALL ( 'BUDGET_COMMITMENTS (2)' ),
            [ACCOUNT] = MAX ( [ACCOUNT] )
                && ( [PeriodKey] ) = MAX ( [PeriodKey] )
        ),
        ABS ( 'BUDGET_COMMITMENTS (2)'[KPI_1_1_Virkelig] )
            - ABS ( 'BUDGET_COMMITMENTS (2)'[KPI_1_1_Budsjett] )
    ) < 0,
    "red",
    "green"
)

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I found it just before you replied, thanks.

 

However, it still does not do as I need it to.

It shows green even when it should not

Column 1 should be red, rest should be green

h4_dkj_0-1626858645759.png

 

Hi, @h4_dkj ;

It is difficult to find out the reason, because the simple data you gave me and tested correct. If possible, you can only make a virtual data by your data . and  ensure that the structure and type of the field and table are the same? then use dax tested it ,  If you are wrong, please share with me virtual data .

Would you be up for a webex or teams tomorrow or friday?

Hi, 

I'm sorry that we only support Community at present. Due to the internal regulations of the company, we do not support other ways of communication in order to ensure the security of customer information. so sorry.

Best Regards,
Community Support Team_ Yalan Wu

okey, since I am new to PBI, please provide a step by step list in order to create a virtual copy and I will try that

Hi,

Copy the original PBIX file, and then replace(change)  the real data. If the data is large, you can delete some data.

I am ready to upload a test version of the PBIX

Hi, @h4_dkj ;

if you can't  find any way of attaching it to this post, you could share excel  or image.

amitchandak
Super User
Super User

@h4_dkj , you can do rule base conditional formatting . Where you can use [real] <150000 red.

 

Of use color measure with filed value option

 

Switch( True(),

[Real] <150000, "red",

"green"

)

How to do conditional formatting by measure and apply it on pie?: https://youtu.be/RqBb5eBf_I4

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

But does that support varians of the target. My budget shows that for month 3 we have estaimated a higher amount then 150 000, so hard coding a number want help me.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors