The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi, I'm quite new with Power BI, and am now trying to figure out how ow to compare columns in the same table and colour the cells based n the comparison. I've tried to look for the answer, but sadly haven't been able to find one for this.
How can I compare the values of two Columns, and colour the column cells based on the comparison? Please see the details below.
EXAMPLE
Comparison 1
Comparing columns B and C. If the value of column C is equal or higher than the value in column B, the cell in column B is coloured red.
Comparison 2
Comparing columns D and E. If the value of column E is less than the value in column D, the cell in column D is coloured red.
Solved! Go to Solution.
Create a measure:
CF Col2 =
IF(SUM('Table'[Col 2])> SUM('Table'[Col 1]), "Orange")
Apply background fx based on this measure
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
Thank you all for the help, I really, really appreciate the help - took me a while, but finally got there.
Hi,
I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
And FYI, the link down below is from Microsoft Learn.
Apply conditional table formatting in Power BI - Power BI | Microsoft Learn
background color condition: =
SWITCH (
TRUE (),
SELECTEDVALUE ( category[Index] ) = 2,
IF (
CALCULATE (
[Sum value:],
FILTER (
ALL ( category ),
category[Index] = 2
)
)
>= CALCULATE (
[Sum value:],
FILTER (
ALL ( category ),
category[Index] = 1
)
),
"Red"
),
SELECTEDVALUE ( category[Index] ) = 4,
IF (
CALCULATE (
[Sum value:],
FILTER (
ALL ( category ),
category[Index] = 4
)
)
<= CALCULATE (
[Sum value:],
FILTER (
ALL ( category ),
category[Index] = 3
)
),
"Red"
)
)
Hi @RolledNatural1
In the first step, you should create measures for every metric like :
after you have all of them you can create a dax code with the condition and color ( by hexa code or a name) :
Result :
the pbix is attached
More guides about conditional formatting here:
https://www.youtube.com/watch?v=mcVoVSXhWmw
https://www.youtube.com/watch?v=m0h3Ghl6mgY
https://www.youtube.com/watch?v=0aifKG_EEYk
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
Create a measure:
CF Col2 =
IF(SUM('Table'[Col 2])> SUM('Table'[Col 1]), "Orange")
Apply background fx based on this measure
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn