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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
PowerRon
Post Patron
Post Patron

DAX formula for conditional formatting column chart

Knipsel1.JPG

Knipsel2.JPG

Knipsel3.JPG

I hope someone can help, cause sometimes propagation and filter context is difficult.

Regards
Ron 

1 ACCEPTED SOLUTION

Here's the measure that works:

Colour3 =
var _differ = MAXX(ALLSELECTED('KPI Dimension'),1-[KPI perc])
var _target = [Check Against Target]
RETURN
SWITCH(
    TRUE(),
    _target >=1, "Green",
    _target < 1 && _target >=_differ, "Purple",
     _target < _differ , "Red"
   
    )

View solution in original post

13 REPLIES 13
PowerRon
Post Patron
Post Patron

Hi @Padycosmos thanx for you answer
I changed the measure as follows (by the way I replaced Amber by Purple, because for Amber it returs Blue, which seems odd)

Color =
var _differ = 1 - [KPI perc]
RETURN
SWITCH(
    TRUE(),
    [Check Against Target] >= 1, "Green",
    [Check Against Target] >= _differ && [Check Against Target] < 1, "Purple",
    [Check Against Target] <= _differ, "Red"
    )
 
Now it returns this
Knipsel1.JPG

So it is already better but 202202 should be Red. 

The funny thing is, when clicking 202202 in the column chart and putting the measure Color in the table, it shows Red
That's really odd

Knipsel1.JPG

You have >=_differ in "Purple" and  <= _differ  in "Red", you need to remove one of the = . Then it should work

Hi @Padycosmos 

unfortunately no change
I changed 

    [Check Against Target] <= _differ, "Red"
into
    [Check Against Target] < _differ, "Red"
 
The tabel shows Red, te column chart Purple for 202202

Could you please move "red" as the first statement, "purple" as the second and "green" as the last and try again?

 

No change @Padycosmos 

Knipsel1.JPG

 

For each row I also selected _differ (Color_Differ)

Knipsel1.JPG

Hope this works

Color =
var _differ = 1 - [KPI perc]
RETURN
SWITCH(
TRUE(),
[Check Against Target] >= 1, "Green",
[Check Against Target] >= _differ && [Check Against Target] < 1, "Purple",
[Check Against Target] < _differ && [Check Against Target] < 1, "Red"
)

If the data is not sensitive, could you please share the pbix file?

 

Hi @Padycosmos 

I can share the pbix file. Looking how to do that, but can't find it. How do I attach a pbix to a reply?

Here's the measure that works:

Colour3 =
var _differ = MAXX(ALLSELECTED('KPI Dimension'),1-[KPI perc])
var _target = [Check Against Target]
RETURN
SWITCH(
    TRUE(),
    _target >=1, "Green",
    _target < 1 && _target >=_differ, "Purple",
     _target < _differ , "Red"
   
    )

You can put the file in your google drive and paste the link here. Please note to enable access to th file for anyone with the link

Hmm, ok , never used google drive. Will try later today. I can also send it personally if I have your email

You may send it to padycosmos@gmail.com

Padycosmos
Solution Sage
Solution Sage

In Power BI, though the display format is %, the numbers are stored as decimals. Please make the following changes and try again

var _differ = 1- [KPI perc]

Replace both the 100s in the SWITCH() to 1 

 

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.