cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
vnqt
Helper IV
Helper IV

Color formatting with 3 conditions

Hello,

 

I need to apply the formatting background of column 2 in Table visual with 3 different conditions : 

 

Column 1Column 2Column 3Column 4
4238
5742
4422
    

Condition 1 : Column 2 = Column 1  : no color

Condition 2 : Column 2 > Column 1 : Red

Condition : Column 3 > Column 4 : Orange

 

Thank you in advance.

 

1 ACCEPTED SOLUTION
Mahesh0016
Solution Sage
Solution Sage

Mahesh0016_0-1671707378071.png

#Measures :

_BGColor1 =
 VAR col1 = SELECTEDVALUE('conditional Formatting'[Column1])
 VAR col2 = SELECTEDVALUE('conditional Formatting'[Column2])
 VAR col3 = SELECTEDVALUE('conditional Formatting'[Column3])
 VAR col4 = SELECTEDVALUE('conditional Formatting'[Column4])

 RETURN
 IF(col2=col1,"#0000FF","Yellow")
 
#Measure_2 :
_BGColor2 =
 VAR col1 = SELECTEDVALUE('conditional Formatting'[Column1])
 VAR col2 = SELECTEDVALUE('conditional Formatting'[Column2])
 VAR col3 = SELECTEDVALUE('conditional Formatting'[Column3])
 VAR col4 = SELECTEDVALUE('conditional Formatting'[Column4])

 RETURN
 IF(col2>col1,"RED","Yellow")
 
#Measure_3 :
_BGColor3 =
 VAR col1 = SELECTEDVALUE('conditional Formatting'[Column1])
 VAR col2 = SELECTEDVALUE('conditional Formatting'[Column2])
 VAR col3 = SELECTEDVALUE('conditional Formatting'[Column3])
 VAR col4 = SELECTEDVALUE('conditional Formatting'[Column4])

 RETURN
 IF(col3>col4,"Orange","Yellow")
 
#Measure_4 : 
_BGColor4 =
 VAR col1 = SELECTEDVALUE('conditional Formatting'[Column1])
 VAR col2 = SELECTEDVALUE('conditional Formatting'[Column2])
 VAR col3 = SELECTEDVALUE('conditional Formatting'[Column3])
 VAR col4 = SELECTEDVALUE('conditional Formatting'[Column4])

 RETURN
 IF(col2>col1,"#00FFFF","Yellow")
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
Mahesh0016
Solution Sage
Solution Sage

Mahesh0016_0-1671707378071.png

#Measures :

_BGColor1 =
 VAR col1 = SELECTEDVALUE('conditional Formatting'[Column1])
 VAR col2 = SELECTEDVALUE('conditional Formatting'[Column2])
 VAR col3 = SELECTEDVALUE('conditional Formatting'[Column3])
 VAR col4 = SELECTEDVALUE('conditional Formatting'[Column4])

 RETURN
 IF(col2=col1,"#0000FF","Yellow")
 
#Measure_2 :
_BGColor2 =
 VAR col1 = SELECTEDVALUE('conditional Formatting'[Column1])
 VAR col2 = SELECTEDVALUE('conditional Formatting'[Column2])
 VAR col3 = SELECTEDVALUE('conditional Formatting'[Column3])
 VAR col4 = SELECTEDVALUE('conditional Formatting'[Column4])

 RETURN
 IF(col2>col1,"RED","Yellow")
 
#Measure_3 :
_BGColor3 =
 VAR col1 = SELECTEDVALUE('conditional Formatting'[Column1])
 VAR col2 = SELECTEDVALUE('conditional Formatting'[Column2])
 VAR col3 = SELECTEDVALUE('conditional Formatting'[Column3])
 VAR col4 = SELECTEDVALUE('conditional Formatting'[Column4])

 RETURN
 IF(col3>col4,"Orange","Yellow")
 
#Measure_4 : 
_BGColor4 =
 VAR col1 = SELECTEDVALUE('conditional Formatting'[Column1])
 VAR col2 = SELECTEDVALUE('conditional Formatting'[Column2])
 VAR col3 = SELECTEDVALUE('conditional Formatting'[Column3])
 VAR col4 = SELECTEDVALUE('conditional Formatting'[Column4])

 RETURN
 IF(col2>col1,"#00FFFF","Yellow")
If this post helps, please consider accept as solution to help other members find it more quickly.
Mahesh0016
Solution Sage
Solution Sage

can you share sample output in table format?

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors