cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
amconnel
Resolver I
Resolver I

DAX Conditional Formatting - Multiple Conditions

Hi, I need some help creating a measure to use for conditional formatting in a matrix. I have the following matrix:

amconnel_0-1623685430352.png

In addition to this, I have a slicer that filters for the following metrics: net sales, COGS, EBITDA, op inc, Gross margin, and SG&A. 

I only need conditional formatting for the "Variance" row. It needs to be based on a couple of conditions. 

 

When COGS or SG&A is selected in the slicer AND variance >= 0, I need the background colored "#FFC7CE"
When COGS or SG&A is selected in the slicer AND variance < 0, I need the background colored "#C6EFCE"

When anything else is selected (i.e. net sales, EBITDA, op inc, and gross margin) AND variance >= 0, background color "#C6EFCE"
When anything else is selected AND variance < 0, background color "#FFC7CE"

 

Any help is appreciated!

1 ACCEPTED SOLUTION
amconnel
Resolver I
Resolver I

I had been having this problem for about two days. Couldn't quite get the solution right, but as soon as I post here, I figured it out. Here's the solution in the event someone coming across this has a similar issue. 

Conditional Formatting =
IF( SELECTEDVALUE(Append3[Metric]) IN {"COGS", "SG&A"} && [Variance] >= 0, 1,
IF( SELECTEDVALUE(Append3[Metric]) IN {"COGS", "SG&A"} && [Variance] < 0, 2,
IF( SELECTEDVALUE(Append3[Metric]) IN {"Net Sales", "EBITDA", "Op Inc", "Gross Margin"} && [Variance] >= 0, 3,
IF( SELECTEDVALUE(Append3[Metric]) IN {"Net Sales", "EBITDA", "Op Inc", "Gross Margin"} && [Variance] < 0, 4))))
 
From here, under conditional formatting for Variance, I chose rules, selected this measure, and assigned the appropriate colors to the corresponding numbers. 
amconnel_0-1623686623974.png

 

View solution in original post

1 REPLY 1
amconnel
Resolver I
Resolver I

I had been having this problem for about two days. Couldn't quite get the solution right, but as soon as I post here, I figured it out. Here's the solution in the event someone coming across this has a similar issue. 

Conditional Formatting =
IF( SELECTEDVALUE(Append3[Metric]) IN {"COGS", "SG&A"} && [Variance] >= 0, 1,
IF( SELECTEDVALUE(Append3[Metric]) IN {"COGS", "SG&A"} && [Variance] < 0, 2,
IF( SELECTEDVALUE(Append3[Metric]) IN {"Net Sales", "EBITDA", "Op Inc", "Gross Margin"} && [Variance] >= 0, 3,
IF( SELECTEDVALUE(Append3[Metric]) IN {"Net Sales", "EBITDA", "Op Inc", "Gross Margin"} && [Variance] < 0, 4))))
 
From here, under conditional formatting for Variance, I chose rules, selected this measure, and assigned the appropriate colors to the corresponding numbers. 
amconnel_0-1623686623974.png

 

View solution in original post

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors