Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
michellen
Frequent Visitor

Trendline Calculation help

Hi all

I have a data for July-Sept and have used a trendline calculation but the trendline is calculating values in months that don't have any data. We are using our own calculation to align to a Trend % change calculation on the page so haven't used the inbuilt one in Analysis. Can anyone advise what I've done wrong in the calculation below? 

michellen_0-1633502232668.png

Trendline_Measure =
VAR Known =
FILTER (SELECTCOLUMNS (
CALCULATETABLE (VALUES ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar') ),
"Known[X]", 'Calendar'[Date],
"Known[Y]", [Event] ),
AND (NOT ( ISBLANK ( Known[X] ) ) , NOT (ISBLANK ( Known[Y]  )  )  )  )
VAR Count_Items = COUNTROWS ( Known )
VAR Sum_X = SUMX ( Known, Known[X] )
VAR Sum_X2 = SUMX ( Known, Known[X] * Known[X] )
VAR Sum_Y = SUMX ( Known, Known[Y] )
VAR Sum_XY = SUMX ( Known, Known[X] * Known[Y] )
VAR Average_X = AVERAGEX ( Known, Known[X] )
VAR Average_Y = AVERAGEX ( Known, Known[Y] )
VAR Slope = DIVIDE (  Count_Items * Sum_XY - Sum_X * Sum_Y,   Count_Items * Sum_X2 - Sum_X * Sum_X )
VAR Intercept = Average_Y - Slope * Average_X
RETURN
SUMX ( DISTINCT ( 'Calendar'[Date] ), Intercept + Slope * 'Calendar'[Date] )
 
2 REPLIES 2
amitchandak
Super User
Super User

@michellen , You are doing a product with * 'Calendar'[Date]?

is the last return correct ?

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak
Link to file with basic data. My formula is extending the trendline beyond the dates of the data. Want to only show a trend between the data points. I'm no guru on trend formulas and copied it from PBI Community. Any help would be appreciated!
Trendline_DAX.pbix 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.