Forecasting

Calculating an Average Annual Growth Rate in MetrixND

September 20, 2017

After finishing my forecast, I like to present forecast average annual growth rates.  These results are calculated by converting the monthly forecast into annual values using a Transformation table with an annual periodicity.  The formulas used in the annual Transformation table are shown below.



In these equations, the “Res” variable sums the monthly residential sales forecast into annual sales using the “SumAcross” function.  The “Res_GrowthRate” variable calculates the year-to-year growth rates using the “PercentLag” function and the newly created “Res” variable.  The results shown below are annual sales and growth rates.



While year-to-year numbers are valuable, most forecasters like to communicate average annual growth rates.  In this case, what is the average annual growth rate for the forecast?  To calculate this, I added two new variables in the annual Transformation table, “SumRange” and “AvgAnnualGrowthRate” as shown below.



The “SumRange” variable isolates the forecast period, which, in this example, begins in 2015.  The variable uses the “IF-THEN-ELSE-ENDIF” function to remove any values which are not defined in the IF condition.  In this case, all the values prior to 2015 are removed as shown below.

The “AvgAnnualGrowthRate” variable takes the “SumRange” results and obtains the average to present the average annual growth in the forecast period.  The key component of this variable is the “GetDStat” function. This function obtains the variable average (mean) from the DStat tab.  The IF condition is used to place the annual average growth rate in the year 2020 row.



Typically, the average annual growth rates are calculated in a spreadsheet.  Forecasters copy and paste results into a spreadsheet where annual averages are easily calculated.  However, using the two variables described above allows for the dynamic calculation of results, removing the need to copy and paste into the spreadsheet.

Si è verificato un errore nell'elaborarazione del modello.
The following has evaluated to null or missing:
==> authorContent.contentFields  [in template "44616#44647#114455" at line 9, column 17]

----
Tip: It's the step after the last dot that caused this error, not those before it.
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
	- Failed at: contentFields = authorContent.content...  [in template "44616#44647#114455" at line 9, column 1]
----
1<#assign 
2	webContentData = jsonFactoryUtil.createJSONObject(author.getData()) 
3	classPK = webContentData.classPK 
4/> 
5 
6<#assign 
7authorContent = restClient.get("/headless-delivery/v1.0/structured-contents/" + classPK + "?fields=contentFields%2CfriendlyUrlPath%2CtaxonomyCategoryBriefs") 
8contentFields = authorContent.contentFields 
9categories=authorContent.taxonomyCategoryBriefs 
10authorContentData = jsonFactoryUtil.createJSONObject(authorContent) 
11friendlyURL = authorContentData.friendlyUrlPath 
12authorCategoryId = "0" 
13/> 
14 
15<#list contentFields as contentField > 
16   <#assign  
17	 contentFieldData = jsonFactoryUtil.createJSONObject(contentField)  
18	 name = contentField.name 
19	 /> 
20	 <#if name == 'authorImage'> 
21	    <#if (contentField.contentFieldValue.image)??> 
22	        <#assign authorImageURL = contentField.contentFieldValue.image.contentUrl />	 
23			</#if> 
24	 </#if> 
25	 <#if name == 'authorName'> 
26	    <#assign authorName = contentField.contentFieldValue.data /> 
27			<#list categories as category > 
28         <#if authorName == category.taxonomyCategoryName> 
29				     <#assign authorCategoryId = category.taxonomyCategoryId /> 
30				 </#if> 
31      </#list> 
32	 </#if> 
33	 <#if name == 'authorDescription'> 
34	    <#assign authorDescription = contentField.contentFieldValue.data /> 
35			 
36	 </#if> 
37	  
38	 <#if name == 'authorJobTitle'> 
39	    <#assign authorJobTitle = contentField.contentFieldValue.data /> 
40			 
41	 </#if> 
42 
43</#list> 
44 
45<div class="blog-author-info"> 
46	<#if authorImageURL??> 
47		<img class="blog-author-img" id="author-image" src="${authorImageURL}" alt="" /> 
48	</#if> 
49	<#if authorName??> 
50		<#if authorName != ""> 
51			<p class="blog-author-name">By <a id="author-detail-page" href="/w/${friendlyURL}?filter_category_552298=${authorCategoryId}"><span id="author-full-name">${authorName}</span></a></p> 
52			<hr /> 
53		</#if> 
54	</#if> 
55	<#if authorJobTitle??> 
56		<#if authorJobTitle != ""> 
57			<p class="blog-author-title" id="author-job-title" >${authorJobTitle}</p> 
58			<hr /> 
59		</#if> 
60	</#if> 
61	<#if authorDescription??> 
62		<#if authorDescription != "" && authorDescription != "null" > 
63			<p class="blog-author-desc" id="author-job-desc">${authorDescription}</p> 
64			<hr /> 
65		</#if> 
66	</#if> 
67</div>