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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Sonia316
Helper I
Helper I

Conditional formatting for one column based on value in another table

I have this table here:

 

Sonia316_0-1655846320049.png

Profile is a SharePoint field drop down.  I have a profile master list that stores all of the data for the stoplight values for each profile.  I want to color code the values of each measurement based on the profile master.  

 

I assume I have to create measures for each profile.  I'm fairly new to PowerBI and I just don't know how to write the measure.

 

color =
SWITCH(
TRUE(),
SELECTEDVALUE('Table'[Group]) = "A" && 'Table'[test] >=1 && 'Table'[test] <=15, "#1E90FF",
SELECTEDVALUE('Table'[Group]) = "B" && 'Table'[test] >=1 && 'Table'[test] <=30, "#00FA9A",
SELECTEDVALUE('Table'[Group]) = "C" && 'Table'[test] >=1 && 'Table'[test] <=45, "#8A2BE2",
"#FF0000"
)

 

4 REPLIES 4
Anonymous
Not applicable

Hi @Sonia316 ,

 

If there is an active relationship between two tables, you can try to use SUM() to catch values in [Test].

color = 
SWITCH (
    TRUE (),
    SELECTEDVALUE ( 'Table'[Group] ) = "A"
        && SUM('Table'[test]) >= 1
        && SUM('Table'[test]) <= 15, "#1E90FF",
    SELECTEDVALUE ( 'Table'[Group] ) = "B"
        && SUM('Table'[test])  >= 1
        && SUM('Table'[test])  <= 30, "#00FA9A",
    SELECTEDVALUE ( 'Table'[Group] ) = "C"
        && SUM('Table'[test])  >= 1
        && SUM('Table'[test])  <= 45, "#8A2BE2",
    "#FF0000"
)

Then add this color measure into conditional formatting.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

color2 =
SWITCH (
TRUE (),
SELECTEDVALUE ( 'Profile Master'[Title] ) = "Transcend 2.0 Trop 1x5.5 GR"
&& SUM('Quality Check'[WidthTop]) >5.600
&& SUM('Quality Check'[WidthTop]) <5.535, "red",
SELECTEDVALUE ( 'Profile Master'[Title] ) = "Transcend 2.0 Trop 1x5.5 GR"
&& SUM('Quality Check'[WidthTop]) >5.595
&& SUM('Quality Check'[WidthTop]) <5.600, "yellow",
SELECTEDVALUE ( 'Profile Master'[Title] ) = "Transcend 2.0 Trop 1x5.5 GR"
&& SUM('Quality Check'[WidthTop]) >5.535
&& SUM('Quality Check'[WidthTop]) <5.540, "yellow",
SELECTEDVALUE ( 'Profile Master'[Title] ) = "Transcend 2.0 Trop 1x5.5 GR"
&& SUM('Quality Check'[WidthTop]) >5.587
&& SUM('Quality Check'[WidthTop]) <5.549, "white",
"#FF0000"
)

 

So I Have the formula - unfortunately though I can only add ONE measure to conditional formatting and there are several different widths for different profiles.  Does that mean I have to continue the formula to add in those additional selected values until I cover each of the profiles?  I'm thinking the answer is yes

when applying it I got this

 

Sonia316_0-1656334746150.png

 

Sonia316
Helper I
Helper I

I'm using this as my JSON in SharePoint

"background-color": "=if(@currentField == '', 'rgba(0, 0, 0, 0.3)', if(@currentField < [$Profile_x003a_IRVWidthA], 'rgba(240, 52, 52, 1)', if(@currentField <= [$Profile_x003a_IRVWidthB], 'rgba(255, 255, 126, 1)', if(@currentField < [$Profile_x003a_IRVWidthC], 'rgba(255, 255, 255, 1)', if(@currentField <= [$Profile_x003a_IRVWidthD], 'rgba(255, 255, 126, 1)', 'rgba(240, 52, 52, 1)')))))"
},

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.