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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
kekepania0529
Helper I
Helper I

Conditional Formatting based on 2 columns - 1 numeric and 1 text

I need to format the background and text colors based on 2 columns. 1 is a numeric column and 1 is a text column. In excel the conditional formatting formula would be: 

  • =AND($Q1<Value,LEFT($I1,3)="Text")
  • =AND($Q13<Value,LEFT($H13,2)<>"Text")

How do I accomplish this in Power BI desktop?

 

kekepania0529_0-1634132025505.png

 

1 ACCEPTED SOLUTION
timg
Solution Sage
Solution Sage

Hi,

In this case you could add a column or measure containing the the colour code you would like to assign with conditional formatting (a measure would be preferable if the condition depends on the aggregation, a calculated column would be preferable if every row of your table should get a colour assigned). Below you will find an example of a file with a calculated column and measure that assign a colour code when conditions are met. By adding conditional formatting based on a field value (select the visual > consitional formatting > advanced controls > format by: field value ) you make the visual apply this colour based on the result in the measure or calculated column.

 

Measure example:

Colour =
IF (
    AND ( SUM ( 'Table'[Value] ) > 20, SUM ( 'Table'[Value] ) < 60 ),
    "#FF0000",
    BLANK ()
)

Column example: 

ColumnColour =
IF (
    AND ( 'Table'[Value] = 10, 'Table'[Category] = "Category A" ),
    "#00FF00",
    BLANK ()
)

Result:

1.PNG

 

Best regards,

 

Tim





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
timg
Solution Sage
Solution Sage

Hi,

In this case you could add a column or measure containing the the colour code you would like to assign with conditional formatting (a measure would be preferable if the condition depends on the aggregation, a calculated column would be preferable if every row of your table should get a colour assigned). Below you will find an example of a file with a calculated column and measure that assign a colour code when conditions are met. By adding conditional formatting based on a field value (select the visual > consitional formatting > advanced controls > format by: field value ) you make the visual apply this colour based on the result in the measure or calculated column.

 

Measure example:

Colour =
IF (
    AND ( SUM ( 'Table'[Value] ) > 20, SUM ( 'Table'[Value] ) < 60 ),
    "#FF0000",
    BLANK ()
)

Column example: 

ColumnColour =
IF (
    AND ( 'Table'[Value] = 10, 'Table'[Category] = "Category A" ),
    "#00FF00",
    BLANK ()
)

Result:

1.PNG

 

Best regards,

 

Tim





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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