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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Thimios
Helper III
Helper III

Measures in Matrix with conditional formating

Hi all,

I have the following matrix with a couple of measures. I need to conditionally format the background for each row of the % FOOD COST measure. Existing capabilities allow for conditional formatting of the measure without taking in mind the line.

2020-06-23 15_02_03-SDv2 - Power BI Desktop.png

Any ideas?

1 ACCEPTED SOLUTION

Hi @Thimios ,

 

You could refer to the following measure:

Measure =
VAR a =
    SELECTEDVALUE ( Table[CATEGORY] )
VAR b =
    SELECTEDVALUE ( Table[%FOOD COST] )
VAR if1 = ( a = "BURGER"
    && b < 0.42 )
    || ( a = "CLUB"
    && b < 0.55 )
    || ( a = "HOTDOG"
    && b < 0.4 )
    || ( a = "PIZZA"
    && b < 0.4 )
VAR if2 = ( a = "BURGER"
    && b >= 0.42
    && b <= 0.44 )
    || ( a = "CLUB"
    && b >= 0.55
    && b <= 0.57 )
    || ( a = "HOTDOG"
    && b >= 0.4
    && b <= 0.42 )
    || ( a = "PIZZA"
    && b >= 0.4
    && B <= 0.42 )
RETURN
    IF ( if1, "green", IF ( if2, "yellow", "red" ) )

Then put this measure into conditional formatting.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

6 REPLIES 6
v-eachen-msft
Community Support
Community Support

Hi @Thimios ,

 

Do you mean to get the following result?

3-1.PNG

Here is the measure:

Measure =
SWITCH (
    SELECTEDVALUE ( TestTable[Name] ),
    "A", "red",
    "B", "yellow",
    "C", "green",
    "D", "gray"
)

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

@v-eachen-msftI'm afraid not. This is the scenario:

2020-06-24 09_22_17-Book1 - Excel.png

Hi @Thimios ,

 

You could refer to the following measure:

Measure =
VAR a =
    SELECTEDVALUE ( Table[CATEGORY] )
VAR b =
    SELECTEDVALUE ( Table[%FOOD COST] )
VAR if1 = ( a = "BURGER"
    && b < 0.42 )
    || ( a = "CLUB"
    && b < 0.55 )
    || ( a = "HOTDOG"
    && b < 0.4 )
    || ( a = "PIZZA"
    && b < 0.4 )
VAR if2 = ( a = "BURGER"
    && b >= 0.42
    && b <= 0.44 )
    || ( a = "CLUB"
    && b >= 0.55
    && b <= 0.57 )
    || ( a = "HOTDOG"
    && b >= 0.4
    && b <= 0.42 )
    || ( a = "PIZZA"
    && b >= 0.4
    && B <= 0.42 )
RETURN
    IF ( if1, "green", IF ( if2, "yellow", "red" ) )

Then put this measure into conditional formatting.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

@v-eachen-msftWorks like a charm, thank you!

Great to understand the logic behind that and all possible applications.

amitchandak
Super User
Super User

@Thimios , you have to format all columns row is not possible with same conditions

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak To put it in terms of your post, Revenue needs to be formatted per Customer. In my case, Revenue needs to have a different color formatting for every single customer.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.