Power BI Line Chart Conditional Formatting

This Power BI tutorial will help you work with conditional formatting in a Power BI Line chart.

Recently, I was working with a Power BI Line chart where I needed to change the Label color so that it would attract the user.

However, one drawback of the Power BI Line chart is that we can not find any conditional formatting option because the conditional formatting option is unavailable in the Power BI line chart.

But, here I will explain one alternative where we can apply conditional formatting and change the line chart label to different colors.

Also, we will discuss how to apply the conditional formatting in a Power BI line chart and display the label color using DAX.

Power BI Line Chart Conditional Formatting

The first image displays a Power BI Line chart with no label color. Now, I would like to change the line chart label color with various colors based on some conditions.

After applying the conditional formatting, the line chart will display with color labels, as shown in the second image.

Conditional Formatting to a line chart in Power BI

How to Apply Conditional Formatting in Power BI Line Chart

I will tell you how to apply conditional formatting in the Power BI Line chart. As I told you above, the line chart has no conditional formatting options, so we need to do one alternative, i.e., using the Power BI Bar chart.

Follow the instructions below to apply conditional formatting in the Power BI Line chart:

  1. Create a bar chart in Power BI.
  2. Apply conditional formatting to the bar chart in Power BI.
  3. Change the bar chart to a line chart in Power BI.

Create a Bar Chart in Power BI

I have a SharePoint list (Finance Sample) that contains below columns with various data types:

ColumnsData Types
Month NameSingle line of text
ProductSingle line of text
SalesCurrency
ProfitCurrency
Units SoldNumber
CountrySingle line of text
Month NumberNumber
SegmentSingle line of text
Conditional Formatting a Line Chart in Power BI

1. Open Power BI Desktop and load data. Then, in the Data pane, we can see our data set.

Power Bi Line Chart Conditional Formatting

2. Under the Visualizations pane, click Stacked column chart. Then, drag Month Name into the X-axis and Sales into the Y-axis.

What is Conditional Formatting in Power BI Line Chart

Apply Conditional Formatting to the Bar Chart in Power BI

1. Under the Visualizations panel, click Format your visual -> select Visual -> Expand Columns -> Expand Color -> click fx.

Power BI Line Chart Conditional Formatting

2. Then, the Color – Categories dialog box opens. In this box, select Format style -> Rules and What field should we base this on? -> Sales.

Line Graph Conditional Formatting in Power BI

3. Next, add some Rules using the + New rule like:

If value >= 0 and < 100000 then #DEEFFF
If value >= 100000 and < 1000000 then #F303E3
If value >= 1000000 and < 1500000 then #59EB05
If value >= 1500000 and < 2000000 then #FD0404
If value >= 2000000 and < Max then #05FAF6

Then click OK.

How to apply conditional formatting to a line chart in Power BI

4. Finally, conditional formatting is applied in the Stacked column chart.

power bi line chart color based on value

Change the Bar Chart to a Line Chart in Power BI

1. Select the Stacked column chart -> under the Visualizations pane, and click Line chart.

power bi line chart different colors based on value

2. At last, the line chart will appear with the below labels [with different colors that I have specified in the rules].

How to Apply Conditional Formatting in Power BI Line Charts

This way, we can apply conditional formatting in the Power BI Line chart.

Power BI Line Chart Conditional Formatting Using DAX

Next, we will see how to apply conditional formatting in the Power BI Line chart using DAX.

After applying the conditional formatting in the Power BI Line chart, the line chart looks like this:

Using DAX Power BI Line Chart Conditional Formatting

First, we need to create a measure to do this by following the below steps:

1. Under the Home tab, click on the New measure.

Power Bi line chart conditional formatting in DAX

2. In the Formula bar, put below the DAX expression. Then click commit.

Total Sales = SUM('Financial Sample'[ Sales])
Power BI Line Chart Conditional Formatting using DAX

3. I create another measure. Then, in the Formula bar, put it below the DAX expression. Then click commit.

Conditional Formatting = IF([Total Sales] >= 1500000,"Green","Red")
Line Graph Conditional Formatting in Power BI using DAX

4. Under the Visualizations pane, click Stacked column chart. Then, drag Month Name into the X-axis and Total Sales into the Y-axis.

Conditional Formatting a Line Chart in Power BI using DAX

5. Under the Visualizations panel, click Format your visual -> select Visual -> Expand Columns -> Expand Color -> click fx.

Power BI Line Chart Conditional Formatting

5. Then, the Color – Categories dialog box opens. In this box, select Format style -> Find value. Then, select What field should we base this on? -> Conditional Formatting. Then click OK.

How to apply conditional formatting to a line chart using DAX in Power BI

6. Select the Stacked column chart -> under the Visualizations pane, and click Line chart.

power bi line chart different colors based on value using DAX

7. Then you see the line chart conditional formatting applied.

How to Apply Conditional Formatting in the Power BI Line Chart using DAX

You can apply conditional formatting in the Power BI Line Chart using DAX.

Conclusion

I hope this tutorial helps you a lot. This tutorial taught us how to apply conditional formatting and change the Power BI line chart label to different colors based on the rule.

Additionally, I explained how to apply the Power BI line chart conditional formatting using DAX.

Moreover, you may like some more Power BI articles: