Power BI: display a variance line in a chart
For some charts, I like to see a straight line that calculate the difference between 2 values and showing the increase or decrease:

I will explain 2 ways to do it, although both versions give the same result, option 1 will show an error message but in spite of that, it works. This article explains how to do it with columns but if you are looking with measures, read Power BI: create an interactive comparison chart.
Option 1
First I will create a column with this formula:
IF(MAX([argument1])>MAX([argument2]),MAX([argument1])*1.3,MAX([argument2])*1.3)

NOTE:
- Format it into “whole number”
- Change “argument” by yours and for the formula below, also “table”
- Change 1.3 if you want the line higher or lower
And 2 measures. The first one:
var xnum1=SUM('table'[argument1]) var xnum2=SUM('table'[argument2]) var xdiff=xnum2-xnum1 Return SWITCH( TRUE(), xdiff=0,IF(NOT(ISBLANK(xnum2)),xdiff), xdiff>0,IF(NOT(ISBLANK(xnum2)),"▲ +"&xdiff), xdiff<=0,IF(NOT(ISBLANK(xnum2)),"▼ "&xdiff) )

The second one:
var xnum1=SUM('Table'[argument1]) var xnum2=SUM('Table'[argument2]) var xdiff=xnum2-xnum1 Return SWITCH( TRUE(), xdiff>0,"#1AAB40", xdiff<=0,"#D64554" )
NOTE: optional, change the color code #1AAB40 (green) and #D64554 (red) by yours

I will create my line and clustered column chart:
![]() |
![]() |
I will configure it, first, in “secondary y-axis”, click 2 times on “values”, it will make disappear the information on the right of the chart:
![]() |
![]() |
NOTE: it is “off” but in fact it is “on”, a kind of bug that may be corrected in the next update
I will remove the line by turning “off”:

I will turn on the “data labels”:
- In “apply settings to”, select my column and in “position (line)”, select “above”
- In “value”, click on the “field” to select the first “measure” and click on the “fx” of “color” to select the second “measure 2”
![]() |
![]() |
![]() |
Once done, the chart will look like this:

Everything look OK but if I select my chart, I can see this icon with this message:

In spite of that, as I said in the beginning, it works but if it is annoyed you, use the option 2.
Option 2
Everything is the same except for the first “measure”, since I will not use it, I need to create a new one:
MAX('table'[argument])

In the “format” field, change “general” to “dynamic” and in the formula bar, put this formula for “format”:
var xnum1=SUM('table'[argument1]) var xnum2=SUM('table'[argument2]) var xdiff=xnum2-xnum1 var result= SWITCH( TRUE(), xdiff=0,IF(NOT(ISBLANK(xnum2)),xdiff), xdiff>0,IF(NOT(ISBLANK(xnum2)),"▲ +"&xdiff), xdiff<=0,IF(NOT(ISBLANK(xnum2)),"▼ "&xdiff) ) Return """"&result

NOTE: by clicking on “format”, I can switch with “measure”
Now I will create my chart but this time, instead to use “column” for the line, I will use the new measure “measure 3” (left picture) and in “value”, I will just click on the “fx” color to select “measure 2” as in option 1 (right picture):
![]() |
![]() |

Before to end, if you prefer to see this variance just above the corresponding column like that:

For option 1, the “column” formula:
IF([argument1]>[argument2],[ argument1]*1.3,[argument2]*1.3)

For option 2, the “measure 3” formula:
var xnum1=SUM('Table'[argument1]) var xnum2=SUM('Table'[argument2]) var xvalue=MAX(xnum1,xnum2) Return xvalue*1.3

NOTE: “format” of “measure 3” is the same formula as option 1, only “measure” of “measure 3” needs to be changed
Interesting Topics
-
Be successfully certified ITIL 4 Managing Professional
Study, study and study, I couldn’t be successfully certified without studying it, if you are interested...
-
Be successfully certified ITIL 4 Strategic Leader
With my ITIL 4 Managing Professional certification (ITIL MP) in the pocket, it was time to go for the...
-
Hide visual and change background color based on selection
Some small tricks to customize the background colour of a text box...
-
Stacked and clustered column chart or double stacked column chart
In excel, I use a lot the combination of clustered and stacked chart...
-
Refresh Power BI
From the Power BI Service, I can set refresh but, for instance, there is no option to do it monthly or each time a change is made...
-
Power BI alerts to be sent by email from an excel file based on condition
I will explain how to send a list of emails from an excel file after creating alerts...