Power BI: create an interactive comparison chart
I will explain how to create a chart that shows the difference between 2 values but:
- Option 1: 1 of the values is based on the selection done by someone with 1 filter
- Option 2: both values are based on the selection done by someone with 2 filters

The chart will allow me to compare 2 values based on the interaction of my audience. I have this data:

This measure is used for both options and it is to calculate in percentage the ticket based on the number:
var blank0=COUNT('table1'[argument1])/CALCULATE(COUNT('table1'[argument1]),ALL('table1'[argument2])) return IF(ISBLANK(blank0),0,blank0)

NOTE:
- Change table1 and argument1/argument2 by yours
- Don’t forget to format in percentage
From now, I will create other measures according to the option.
Option 1
I will create this measure to calculate in percentage how many tickets with number between 0 and 6:
CALCULATE(CALCULATE(COUNT('table1'[argument1]),'table1'[argument2]>=xx1 && 'table1'[argument2]<=xx2)/COUNT('table1'[argument1]),ALL('table1'[argument2]))

NOTE:
- Change xx1 and xx2 by yours
- Don’t forget to format in percentage
- Result will not change, no matter what I will select on the filter
I will create a clustered column chart and a filter:
![]() |
![]() |
By using the filter, the result of the “measure” will change and since “measure 2” is stable, I can compare easily both results:


To make my life easier, I will add a variance line so I don’t need to calculate the difference. For that, I will adapt the option 2 of my article Power BI: display a variance line in a chart (the article makes reference to columns instead of measures) so my dynamic measure:


var xdiff=[measure1]-[measure2] var result= SWITCH( TRUE(), xdiff=0,FORMAT(xdiff,"0%"), xdiff>=0,"▲ +"&((FORMAT([measure1],"0.00")*100)-(FORMAT([measure2],"0.00")*100))&"%", xdiff<0,"▼ "&((FORMAT([measure1],"0.00")*100)-(FORMAT([measure2],"0.00")*100))&"%" ) Return """"&result
NOTE:
- Change measure1 and measure2 by yours
- Using the formula above, it will show a “variance line” but if I want to display a “monthly variance” (just above the month), use this formula:
IF(VALUE([measure1])>VALUE([measure2]),VALUE([measure1])*1.2,VALUE([measure2])*1.2)


And my coloring measure:
var xdiff=[measure1]-[measure2] Return SWITCH( TRUE(), xdiff>=0,"#1AAB40", xdiff<0,"#D64554" )

I will change my chart to a line and clustered column:

Then I will configure the “y-axis” and the “second y-axis” (skip this configuration if you will use the “monthly variance”):
![]() |
![]() |
This is the result:

Option 2
I will have to upload the same data then I will create an inactive relationship:

I will create a measure:
var blank0=CALCULATE(COUNT('table1'[argument1])/CALCULATE(COUNT('table1'[argument1]),ALL('table2'[argument2])),USERELATIONSHIP('table1'[argument1],'table2'[argument1])) return IF(ISBLANK(blank0),0,blank0)

NOTE: don’t forget to format in percentage
My dynamic measure:


NOTE: as for option 1, if I want the “monthly variance” (to display them just above the month), I will use the same formula:

My coloring measure:

I will create my line and clustered column chart and 2 slicers:
![]() |
![]() |
![]() |
Then configure the “y-axis” and the “second y-axis” like in option 1 (again, skip this configuration if you will use the “monthly variance”). This is the result:


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...