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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

how to color the background of a field in a table based on another field

Hello,

 

I have a table which contains employees info such as employeeID and other field.  Among the other field, we have Termination time which can take only 3 values (T6 (terminated within 6 months), T6+ (terminated more than six months ago) and NT (not Terminated).

 

I would like to have the EmployeeID background based on those 3 values.

Does someone know how to do that?

Regards,

 

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@Anonymous 

You can write a measure to return the color you want based on the [Termination Time] for that user then apply conditional formatting to the user name field based on that measure.

 

 

Name Format = 
VAR _TermTime = SELECTEDVALUE ( 'Your Table'[Termination Time] )
RETURN
SWITCH ( 
    _TermTime,
    "NT", "Green",
    "T6", "Yellow",
    "T6+", "Red")

 

 

conditionalformat2020.jpg

 

conditionalformat2020Table.jpg

 

You can use either CSS color names or the hex codes.  Here is a site to find a decent color range that will let you pick a color and see the hex code for it.

https://htmlcolorcodes.com/color-chart/

 

View solution in original post

1 REPLY 1
jdbuchanan71
Super User
Super User

@Anonymous 

You can write a measure to return the color you want based on the [Termination Time] for that user then apply conditional formatting to the user name field based on that measure.

 

 

Name Format = 
VAR _TermTime = SELECTEDVALUE ( 'Your Table'[Termination Time] )
RETURN
SWITCH ( 
    _TermTime,
    "NT", "Green",
    "T6", "Yellow",
    "T6+", "Red")

 

 

conditionalformat2020.jpg

 

conditionalformat2020Table.jpg

 

You can use either CSS color names or the hex codes.  Here is a site to find a decent color range that will let you pick a color and see the hex code for it.

https://htmlcolorcodes.com/color-chart/

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors