Home » Power BI » Conditional formatting by field value in Power BI

Conditional formatting by field value in Power BI

Power BI Conditional Formatting Field Value

In Power BI you can apply conditional formatting based on field value, you can achieve this by creating a measure that contains condition with a hex name/color code.

Let’s get started

Download the sample Dataset from below link-




Follow these steps in order to implement conditional formatting by field value-

Step-1: Drag clustered column chart to Power BI report page with Region & Sales column.

Clustered Column chart

Clustered Column chart

Step-2: Now create a measure with below mentioned condition.

Change Sales Color =
VAR TotalSales = SUM ( 'Global-Superstore'[Sales] )
RETURN
IF (
TotalSales < 900000,
"#FF0000", --Red color
IF (
TotalSales > 900000,
"#008000" --Green Color
)
)



Measure Description: Change color based on condition, if sum of sales is greater than 900000 then change color to Green else Red.

Step-3: Now implement the conditional formatting on chart-

Select chart > go to format bar > click on fx icon under data colors tab.

Change color for Clustered column chart

Change color for Clustered column chart



Step-4: Data colors dialog box opens, follow below steps, then click on ok button.

  • Format by : Choose Field value.
  • Based on field: Select your measure.
Conditional formatting field value

Conditional formatting field value

Step-5: See the output, based on condition color has been changed.

Chart color change conditional formatting

Chart color change conditional formatting



Now change the Table visual value color based on field value condition

Step-1: Take Table visual with Region & Sales field.

Then right click on Sales field > Conditional formatting > font color

Change table value font color

Change table value font color



Step2: Font color dialog box opens, follow below steps, then click on ok button.

  • Format by : Choose Field value.
  • Based on field: Select your measure.
Change font color based on value

Change font color based on value

Step-3: See the output, font color has been changed based on the conditions.

Table visual value color change

Table visual value color change

Same conditional formatting you can implement for Matrix visual to change the value color based on conditions.

Refer other Power BI topics: Power BI tutorials



Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our Contact form , we will revert to you asap.

Leave a Reply