Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
techen1
Contributor
Contributor

Trendline macro - forecast / equation / line style

Hello,

i've created a macro to enable/disable linear trend lines for my bar charts.

 

sub AddTrendlines
For x = 0 to 5 'NoOfReportPages 
 Objects = ActiveDocument.GetSheet(x).GetSheetObjects
    For i = lBound(Objects) To uBound(Objects)
	    OT = Objects(i).GetObjectType
	    ObjectID = Objects(i).GetObjectID
	      if(OT = 12) then
		    set prop = Objects(i).GetProperties
			set expr = prop.Expressions
			c=expr.Count - 1
			for j = 0 to c
				Objects(i).AddTrend j,1,1
			next
		 end if
	next
 Next
 ActiveDocument.Variables("vLinearTrendline").SetContent "1", true      
end sub

sub RemoveTrendlines
For x = 0 to 5 'NoOfReportPages 
 Objects = ActiveDocument.GetSheet(x).GetSheetObjects
    For i = lBound(Objects) To uBound(Objects)
	    OT = Objects(i).GetObjectType
	    ObjectID = Objects(i).GetObjectID
	     if(OT = 12) then
		    set prop = Objects(i).GetProperties
			set expr = prop.Expressions
			c=expr.Count - 1
			for j = 0 to c
				Objects(i).RemoveTrend j,1,1
			next
		end if
	next
 Next
 ActiveDocument.Variables("vLinearTrendline").SetContent "0", true    
end sub

 

 

I would like to extend the macro "AddTrendlines" by the following things:

- Display equation (expression tab)

- Set a forecast value of 3 (axis tab)

- Change line style to dotted

 

I don't know how to realise these things via macro.

thx 4 your help.

Labels (2)
2 Replies
Ryan69
Contributor
Contributor

A trend line indicates a linear relationship. The equation for a linear relationship is y = mx + b, where x is the independent variable, y is the dependent variable, m is the slope of the line, and b is the y-intercept.
Clover.com

techen1
Contributor
Contributor
Author

Unfortunately your answer does not help me 😞