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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
TTPP81
Frequent Visitor

Set color in one column using value from another column

Hi, I would like to set a condition whereby if the value in "date range' column shows 'within date range', the rating column and true rating outcome will change color depending on whether it is MOD (YELLOW) & SUS (GREEN). May i know how can i achieve this?condition formatting

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @TTPP81 ,

 

You can create measures that adjust your formatting, for example:

CondFmt_Rating = 
VAR __timeValue = SELECTEDVALUE(CF_Test_Table[Date Range])
VAR __ratingValue = SELECTEDVALUE(CF_Test_Table[Rating])
RETURN
SWITCH(
    TRUE(),
    __timeValue = "Within" && __ratingValue = "MOD", "#FEC0BF",  // your yellow hex code
    __timeValue = "Within" && __ratingValue = "SUS", "#99E3DD"   // your green hex code
)

CondFmt_TrueRating = 
VAR __timeValue = SELECTEDVALUE(CF_Test_Table[Date Range])
VAR __trueValue = SELECTEDVALUE(CF_Test_Table[True Rating])
RETURN
SWITCH(
    TRUE(),
    __timeValue = "Within" && __trueValue = "MOD", "#FEC0BF",  // your yellow hex code
    __timeValue = "Within" && __trueValue = "SUS", "#99E3DD"   // your green hex code
)

 

Once you've created the measures, you apply them to the visual using Cell Elements > Series (the column you want to format) > Background Colour (fx) > Field Value > select conditional format measure from dropdown list.

BA_Pete_0-1727432453715.png


In this example, I get the following output:

BA_Pete_1-1727432497615.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

Hi @TTPP81 ,

 

You can create measures that adjust your formatting, for example:

CondFmt_Rating = 
VAR __timeValue = SELECTEDVALUE(CF_Test_Table[Date Range])
VAR __ratingValue = SELECTEDVALUE(CF_Test_Table[Rating])
RETURN
SWITCH(
    TRUE(),
    __timeValue = "Within" && __ratingValue = "MOD", "#FEC0BF",  // your yellow hex code
    __timeValue = "Within" && __ratingValue = "SUS", "#99E3DD"   // your green hex code
)

CondFmt_TrueRating = 
VAR __timeValue = SELECTEDVALUE(CF_Test_Table[Date Range])
VAR __trueValue = SELECTEDVALUE(CF_Test_Table[True Rating])
RETURN
SWITCH(
    TRUE(),
    __timeValue = "Within" && __trueValue = "MOD", "#FEC0BF",  // your yellow hex code
    __timeValue = "Within" && __trueValue = "SUS", "#99E3DD"   // your green hex code
)

 

Once you've created the measures, you apply them to the visual using Cell Elements > Series (the column you want to format) > Background Colour (fx) > Field Value > select conditional format measure from dropdown list.

BA_Pete_0-1727432453715.png


In this example, I get the following output:

BA_Pete_1-1727432497615.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors
Top Kudoed Authors