Power BI: trend line
The easier way to put a trend line is to put in the “x-axis” of the chart a number. For instance, instead to put the month name “January, February, etc.”, put “1, 2, etc” or whatever numbers then make sure to have the “continuous” (not categorical) type selected (left picture) and the “trend line” option will appear (right picture):
![]() |
![]() |
Now if this option doesn’t appear, this is how I will create it. Let´s take an example, this is my data and my chart:
![]() |
![]() |

First, I will create 3 columns:
- A new index column with this formula: IF(NOT(ISBLANK('table'[value])),'table'[index])
it will allow to keep the trend line in progress based on the last data. For instance:
- A trend number column: it will calculate where to put each point to draw the line
- A trend line column: it will allow to draw the increase/decrease/equal line

This is the formula for the trend number:
var xdiff=put-a-number // put a number to where to start and to end the trend line var xstart=CALCULATE(MIN('table'[value]),FILTER(ALL('table'),'table'[new index]=MIN('table'[new index]))) var xend=CALCULATE(MAX('table'[value]),FILTER(ALL('table'),'table'[new index]=MAX('table'[new index]))) var xnbmonth=COUNT('table'[value])-1 var xilastvalue=CALCULATE(MAX('table'[value]),FILTER(ALL('table'),'table'[new index]=MAX('table'[new index])))-xdiff var xinbunique=IF(NOT(ISBLANK(VALUE('table'[value]))),(xilastvalue-xdiff)/xnbmonth) var xdmainvalue=CALCULATE(MIN('table'[value]),FILTER(ALL('table'),'table'[new index]=MIN('table'[new index])))-xdiff var xdnbunique=IF(NOT(ISBLANK(VALUE('table'[value]))),(xdmainvalue-xdiff)/xnbmonth) var xdecrease=IF('table'[new index]=1,0,xdnbunique) var xincrease=IF(NOT(ISBLANK(CALCULATE(MIN('table'[value]),'table'[new index]=MIN('table'[new index])))),xdiff,xinbunique) return IF(xend<xstart,xdecrease,IF(xend>xstart,xincrease))

This is the formula for the trend line:
var xdiff=put-a-number // put a number to where to start and to end the trend line var xstart=CALCULATE(MIN('table'[value]),FILTER(ALL('table'),'table'[new index]=MIN('table'[new index]))) var xend=CALCULATE(MAX('table'[value]),FILTER(ALL('table'),'table'[new index]=MAX('table'[new index]))) var xdmainvalue=CALCULATE(MIN('table'[value]),FILTER(ALL('table'),'table'[new index]=MIN('table'[new index])))-xdiff var xincrease=CALCULATE(SUM('table'[trend number]),FILTER('table','table'[new index]<=EARLIER('table'[new index]))) var xdecrease=IF(NOT(ISBLANK('table'[new index])),xdmainvalue-CALCULATE(SUM('table'[trend number]),FILTER('table','table'[new index]<=EARLIER('table'[new index])))) Return IF(xend<xstart,xdecrease,IF(xend>xstart,xincrease,IF(xend=xstart,IF(NOT(ISBLANK('table'[new index])),xstart/2))))

NOTE:
- Change “table”, “value”, “new index” and “trend number” by yours
- Change “put-a-number” by yours. If I put 0, the trend line will go from the top to the bottom like that:
Once I will add the trend line in the “line y-axis”, this is the result for the full year:
![]() |
![]() |
Now I don’t know why but for some reports, I got a circular dependency error message for the “trend line” formula, in this case, the workaround is to export the “month” and the “new index” columns in a new table and create another trend line column:

This is the formula to create the table2:
SELECTCOLUMNS('table',"name column",[argument1],"name column",[argument2])
This is the formula to create the new trend line column:
var xdiff=put-a-number // put a number to where to start and to end the trend line var xstart=CALCULATE(MIN('table1'[value]),FILTER(ALL('table1'),'table1'[new index]=MIN('table1'[new index]))) var xend=CALCULATE(MAX('table1'[value]),FILTER(ALL('table1'),'table1'[new index]=MAX('table1'[new index]))) var xdmainvalue=CALCULATE(MIN('table1'[value]),FILTER(ALL('table1'),'table1'[new index]=MIN('table1'[new index])))-xdiff var xincrease=CALCULATE(SUM('table1'[trend number]),FILTER('table1','table1'[new index]<=EARLIER('table2'[new index]))) var xdecrease=IF(NOT(ISBLANK('table2'[new index])),xdmainvalue-CALCULATE(SUM('table1'[trend number]),FILTER('table1','table1'[new index]<=EARLIER('table2'[new index])))) Return IF(xend<xstart,xdecrease,IF(xend>xstart,xincrease,IF(xend=xstart,IF(NOT(ISBLANK('table2'[new index])),xstart/2))))

Once done, I can delete the column with the circular dependency error and use this new trend line for my chart but first, I will have to create a relationship like that:

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