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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
coyote_ptm
Frequent Visitor

Conditional formatting on dimension attribute

I have seen similar posts regarding this, but they don't seem to be usable in my scenario. I'd like to format a measure with different background colors based on an attribute from a dimension table. Different colors if measure is above or below the dimension.

 

LaborHours[Charge Ability PCT] is the measure and Employees[TargetRatio] is the attribute to base the formatting on.

// the join between tables
LaborHours[Employee] = Employees[Employee]

// the measure
Charge Ability PCT = IF( SUM( LaborHours[Chargeable Hours] ) == 0, 0, 
                         SUM( LaborHours[Billable Hours] ) / SUM( LaborHours[Chargeable Hours] ) )

 

I have used a separate "color" field before when using a summary table, but the dimensional attribute is included in the summary table. The summary table will go away as soon as I get this issue resolved.

TargetReached = IF( ChargeAbility[ChargeabilityPCT] == 0, "#FFFFF", IF( ChargeAbility[ChargeabilityPCT] < ChargeAbility[ Target Ratio], "#FF7C80" , "#A9D08E" ) )

If I try the same formula in the LaborHours table referencing the Employees table, I get an error - can't use employees in this expression.

coyote_ptm_0-1629490828287.png

 

Is there a way to work around this?

 

2 REPLIES 2
amitchandak
Super User
Super User

@coyote_ptm , You need to use related, relatedtable of MAXX to filter and bring that in a new calculated column

 

refer 4 ways to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

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

Following up.  I brought the Target Ratio into the LaborHours table.

New column:

 

Target Ratio = LOOKUPVALUE( Employees[ Target Ratio], Employees[Employee], LaborHours[Employee] )

 

 

Created Average measure of target ratio:

 

 

Target Ratio Measure = AVERAGE( LaborHours[Target Ratio] )/100

 

 

This was the issue for me - I didn't create this as a measure and it didn't work.  It would always be 1 color because it was comparing to each row in the fact table, not the sum of the fact table.

 

Met Charge Color = IF( LaborHours[Charge Ability PCT]  == 0, "#FFFFF", IF( LaborHours[Charge Ability PCT]  <  LaborHours[Target Ratio Measure]  , "#FF7C80" , "#A9D08E" ) )

 

 

coyote_ptm_0-1630608278268.png

 

It's too bad it couldn't just use the ratio from the employee table without adding to labor hours table, but this works for now.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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