cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

## Adding Last 12 Months Average Sales as Constant Trend Line in Line Chart

Hi Experts,

I am calculating the Last 12 Months Average Sales as a Constant Trend Line.

Line Chart:
X Axis: Date Dimension
Y Axis: Sum of Sales

Requirement:

• I need to add a trendline that represents the "Last 12 Months Average Sales."
• For the trendline, based on the year filtered (2024) and month filtered (July), the Last 12 Months Average Sales is \$2008.00. You can refer to the attached Excel file for the Last 12 Months Average Sales calculation.

Average Sales Past 12 Month.xlsx

I need to add a constant trend line in the line chart similar to the illustrated image provided.

I have also attached a PBIX file for your reference.

12Months-AverageSalesTrendLine.pbix

Thank you!

1 ACCEPTED SOLUTION
Super User

@puru85 , Last 12 month Avg, based on max selected date, you need a measure like below

12 Month Avg =
var _max = maxx(allselected('Date'), 'Date'[Date])
return
CALCULATE(AverageX(Values('Date'[MONTH Year]),calculate(Sum('Table'[Value])))
,DATESINPERIOD('Date'[Date ],_max,-12,MONTH))

Make sure you are using a date table connected with the date of your table. And field from the date table is used in Slicer, visual, and Measure

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Super User

@puru85 , Last 12 month Avg, based on max selected date, you need a measure like below

12 Month Avg =
var _max = maxx(allselected('Date'), 'Date'[Date])
return
CALCULATE(AverageX(Values('Date'[MONTH Year]),calculate(Sum('Table'[Value])))
,DATESINPERIOD('Date'[Date ],_max,-12,MONTH))

Make sure you are using a date table connected with the date of your table. And field from the date table is used in Slicer, visual, and Measure

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.