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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
michaelag
Frequent Visitor

Dax Conditional Formatting

Hi I have struggled for few days now reading posts and trying all variations on how to build a conditional DAX and no matter which way i do it, it doesn't give me the result that I'm after.....
My original DAX is calculating diff sections as per below and what I'm after is one DAX that can change the colours accordingly, posted below too

 

Selected_Actual_Values_Performance% =
VAR CurrentItem=SELECTEDVALUE('Performance % Template'[Perforamnce %])


RETURN
SWITCH(TRUE(),
CurrentItem="Revenue %",[All_Income_VarPerc],
CurrentItem="Parts Mix %",[Parts_RatioPerc_Var],
CurrentItem="Panel GP %",[Panel_GP_Perc_Var],
CurrentItem="Parts GP %",[Parts_GPPerc Var],
CurrentItem="Paint GP %",[Paint_GPPerc_Var],
CurrentItem="Sublet GP %",[Sublet_GPPerc_Var],
CurrentItem="Liquid %",[Paint Liquid Perc Var to Budget],
CurrentItem="Consumables %",[Paint_Panel_ConsumablesPerc_Var],
CurrentItem="Overheads %",[OPS_ExpensesPerc_Var],
CurrentItem="Office Wages %",[Office Wages RatioPerc Var to Bud],
CurrentItem="Total GP %",[OPS_Total_GPPerc_Var],
CurrentItem="EBITDA %",[OPS_EBITDAPerc_Var])

Colours 
Selected_Actual_Vaues_Performance%_Colour =
SWITCH(TRUE(),
[All_Income_VarPerc]<=0.00,"Red","Green",
[Parts_RatioPerc_Var]>=0.00,"Red","Green",
[Panel_GP_Perc_Var]<=0.00,"Red","Green",
[Parts_GPPerc Var]<=0.00,"Red","Green",
[Paint_GPPerc_Var]<=0.00,"Red","Green",
[Sublet_GPPerc_Var]<=0.00,"Red","Green",
[Paint Liquid Perc Var to Budget]<=0.00,"Green","Red",
[Paint_Panel_ConsumablesPerc_Var]>=0.00,"Red","Green",
[OPS_ExpensesPerc_Var]<=0.00,"Green","Red",
[Office Wages RatioPerc Var to Bud]<=0.00,"Green","Red",
[OPS_Total_GPPerc_Var]<=0.00,"Red","Green",
[OPS_EBITDAPerc_Var]<=0.00,"Red","Green")
 
Looking forward to suggestions on how to get past this
 
thank you
1 ACCEPTED SOLUTION
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @michaelag ,

 

try this.

Selected_Actual_Vaues_Performance%_Colour =
VAR CurrentItem =
    SELECTEDVALUE ( 'Performance % Template'[Perforamnce %] )
RETURN
    SWITCH (
        TRUE (),
        CurrentItem = "Revenue %", IF ( [All_Income_VarPerc] <= 0.00, "Red", "Green" ),
        CurrentItem = "Parts Mix %", IF ( [Parts_RatioPerc_Var] >= 0.00, "Red", "Green" ),
        CurrentItem = "Panel GP %", IF ( [Panel_GP_Perc_Var] <= 0.00, "Red", "Green" ),
        CurrentItem = "Parts GP %", IF ( [Parts_GPPerc Var] <= 0.00, "Red", "Green" ),
        CurrentItem = "Paint GP %", IF ( [Paint_GPPerc_Var] <= 0.00, "Red", "Green" ),
        CurrentItem = "Sublet GP %", IF ( [Sublet_GPPerc_Var] <= 0.00, "Red", "Green" ),
        CurrentItem = "Liquid %", IF ( [Paint Liquid Perc Var to Budget] <= 0.00, "Green", "Red" ),
        CurrentItem = "Consumables %", IF ( [Paint_Panel_ConsumablesPerc_Var] >= 0.00, "Red", "Green" ),
        CurrentItem = "Overheads %", IF ( [OPS_ExpensesPerc_Var] <= 0.00, "Green", "Red" ),
        CurrentItem = "Office Wages %", IF ( [Office Wages RatioPerc Var to Bud] <= 0.00, "Green", "Red" ),
        CurrentItem = "Total GP %", IF ( [OPS_Total_GPPerc_Var] <= 0.00, "Red", "Green" ),
        CurrentItem = "EBITDA %", IF ( [OPS_EBITDAPerc_Var] <= 0.00, "Red", "Green" )
    )

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


View solution in original post

2 REPLIES 2
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @michaelag ,

 

try this.

Selected_Actual_Vaues_Performance%_Colour =
VAR CurrentItem =
    SELECTEDVALUE ( 'Performance % Template'[Perforamnce %] )
RETURN
    SWITCH (
        TRUE (),
        CurrentItem = "Revenue %", IF ( [All_Income_VarPerc] <= 0.00, "Red", "Green" ),
        CurrentItem = "Parts Mix %", IF ( [Parts_RatioPerc_Var] >= 0.00, "Red", "Green" ),
        CurrentItem = "Panel GP %", IF ( [Panel_GP_Perc_Var] <= 0.00, "Red", "Green" ),
        CurrentItem = "Parts GP %", IF ( [Parts_GPPerc Var] <= 0.00, "Red", "Green" ),
        CurrentItem = "Paint GP %", IF ( [Paint_GPPerc_Var] <= 0.00, "Red", "Green" ),
        CurrentItem = "Sublet GP %", IF ( [Sublet_GPPerc_Var] <= 0.00, "Red", "Green" ),
        CurrentItem = "Liquid %", IF ( [Paint Liquid Perc Var to Budget] <= 0.00, "Green", "Red" ),
        CurrentItem = "Consumables %", IF ( [Paint_Panel_ConsumablesPerc_Var] >= 0.00, "Red", "Green" ),
        CurrentItem = "Overheads %", IF ( [OPS_ExpensesPerc_Var] <= 0.00, "Green", "Red" ),
        CurrentItem = "Office Wages %", IF ( [Office Wages RatioPerc Var to Bud] <= 0.00, "Green", "Red" ),
        CurrentItem = "Total GP %", IF ( [OPS_Total_GPPerc_Var] <= 0.00, "Red", "Green" ),
        CurrentItem = "EBITDA %", IF ( [OPS_EBITDAPerc_Var] <= 0.00, "Red", "Green" )
    )

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Thank you 🙂 Worked a treat 🙂 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors