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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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