<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Rolling Last 24 Months Metric - Line Chart in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Rolling-Last-24-Months-Metric-Line-Chart/m-p/2448132#M97802</link>
    <description>&lt;P&gt;Hello all!&lt;BR /&gt;&lt;BR /&gt;I'm developing an application to compare my real Demands against my Forecast data.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have a primary key called &lt;STRONG&gt;"%PairKey"&lt;/STRONG&gt; that represents a specific material in a specific region. This material has an &lt;STRONG&gt;Acq Cost&lt;/STRONG&gt;, and I have a date column called &lt;STRONG&gt;"Forecast Slice Date"&lt;/STRONG&gt;, that is a month/year info.&lt;BR /&gt;&lt;BR /&gt;Each Forecast Slice Date, for each PairKey, has a Forecast Value and a real Demanded value. Example below:&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="forecast.png" style="width: 517px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/165306iB1EA36FC1AA57976/image-size/large?v=v2&amp;amp;px=999" role="button" title="forecast.png" alt="forecast.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I calculate my financial accuracy in L24M by making it this way:&lt;BR /&gt;Total Forecast (L24M) = Acq Cost * Forecast Qty L24M&lt;BR /&gt;Total Demand (L24M) = Acq Cost * Demanded Qty L24M&lt;BR /&gt;&lt;BR /&gt;See how I do it (validated) in my text object:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;=

	Num (
	
		// "1 - " because Deviation is what is calculated, so we define Accuracy as the inverse
		Fabs (1 -
	
		// Absolute difference between Demanded and Forecast
	
		Fabs (
		
			Sum (
			
				Aggr (
			
					Sum ( [Forecast Qty] ) * [Acq Cost]
					
				, [%PairKey] )
			
			)
			
			-
			
			Sum (
			
				Aggr (
			
					Sum ( [Demanded Qty] ) * [Acq Cost]
					
				, [%PairKey] )
			
			)
		)
		
		// Divided by Demand (real value that is intended to predict)
		/
		Sum (
			
				Aggr (
			
					Sum ( [Demanded Qty] ) * [Acq Cost]
					
				, [%PairKey] )
			
			)
	
	) * 100
	
	, '#.##0,00')

		&amp;amp; '%'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;When I make L24M selections on Forecast Slice Date, it calculates correctly (around 84%).&lt;BR /&gt;&lt;BR /&gt;But I want a line chart when, for each month in timeline, it calculates the L24M, like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="paulinhok14_0-1714685293879.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/165307iFAF42044BAECE916/image-size/medium?v=v2&amp;amp;px=400" role="button" title="paulinhok14_0-1714685293879.png" alt="paulinhok14_0-1714685293879.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Is there any easy way to do it without changing script?&lt;BR /&gt;&lt;BR /&gt;I've tried, without success, to build a table chart with "Forecast Slice Date" in Dimension and an Expression like that:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;=

	Num (
	
		// "1 - " because Deviation is what is calculated, so we define Accuracy as the inverse
		Fabs (1 -
	
		// Absolute difference between Demanded and Forecast
	
		Fabs (
		
			Sum (
			
				Aggr (
			
					Sum ( {&amp;lt; [Forecast Slice Date] = {"&amp;gt;$(=AddMonths ( Max ( [Forecast Slice Date] ), -24 ) )"} &amp;gt;} [Forecast Qty] ) * [Acq Cost]
					
				, [%PairKey] )
			
			)
			
			-
			
			Sum (
			
				Aggr (
			
					Sum ( [Demanded Qty] ) * [Acq Cost]
					
				, [%PairKey] )
			
			)
		)
		
		// Divided by Demand (real value that is intended to predict)
		/
		Sum (
			
				Aggr (
			
					Sum ( [Demanded Qty] ) * [Acq Cost]
					
				, [%PairKey] )
			
			)
	
	) * 100
	
	, '#.##0,00')

		&amp;amp; '%'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Any ideas?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 02 May 2024 21:33:12 GMT</pubDate>
    <dc:creator>paulinhok14</dc:creator>
    <dc:date>2024-05-02T21:33:12Z</dc:date>
    <item>
      <title>Rolling Last 24 Months Metric - Line Chart</title>
      <link>https://community.qlik.com/t5/App-Development/Rolling-Last-24-Months-Metric-Line-Chart/m-p/2448132#M97802</link>
      <description>&lt;P&gt;Hello all!&lt;BR /&gt;&lt;BR /&gt;I'm developing an application to compare my real Demands against my Forecast data.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have a primary key called &lt;STRONG&gt;"%PairKey"&lt;/STRONG&gt; that represents a specific material in a specific region. This material has an &lt;STRONG&gt;Acq Cost&lt;/STRONG&gt;, and I have a date column called &lt;STRONG&gt;"Forecast Slice Date"&lt;/STRONG&gt;, that is a month/year info.&lt;BR /&gt;&lt;BR /&gt;Each Forecast Slice Date, for each PairKey, has a Forecast Value and a real Demanded value. Example below:&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="forecast.png" style="width: 517px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/165306iB1EA36FC1AA57976/image-size/large?v=v2&amp;amp;px=999" role="button" title="forecast.png" alt="forecast.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I calculate my financial accuracy in L24M by making it this way:&lt;BR /&gt;Total Forecast (L24M) = Acq Cost * Forecast Qty L24M&lt;BR /&gt;Total Demand (L24M) = Acq Cost * Demanded Qty L24M&lt;BR /&gt;&lt;BR /&gt;See how I do it (validated) in my text object:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;=

	Num (
	
		// "1 - " because Deviation is what is calculated, so we define Accuracy as the inverse
		Fabs (1 -
	
		// Absolute difference between Demanded and Forecast
	
		Fabs (
		
			Sum (
			
				Aggr (
			
					Sum ( [Forecast Qty] ) * [Acq Cost]
					
				, [%PairKey] )
			
			)
			
			-
			
			Sum (
			
				Aggr (
			
					Sum ( [Demanded Qty] ) * [Acq Cost]
					
				, [%PairKey] )
			
			)
		)
		
		// Divided by Demand (real value that is intended to predict)
		/
		Sum (
			
				Aggr (
			
					Sum ( [Demanded Qty] ) * [Acq Cost]
					
				, [%PairKey] )
			
			)
	
	) * 100
	
	, '#.##0,00')

		&amp;amp; '%'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;When I make L24M selections on Forecast Slice Date, it calculates correctly (around 84%).&lt;BR /&gt;&lt;BR /&gt;But I want a line chart when, for each month in timeline, it calculates the L24M, like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="paulinhok14_0-1714685293879.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/165307iFAF42044BAECE916/image-size/medium?v=v2&amp;amp;px=400" role="button" title="paulinhok14_0-1714685293879.png" alt="paulinhok14_0-1714685293879.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Is there any easy way to do it without changing script?&lt;BR /&gt;&lt;BR /&gt;I've tried, without success, to build a table chart with "Forecast Slice Date" in Dimension and an Expression like that:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;=

	Num (
	
		// "1 - " because Deviation is what is calculated, so we define Accuracy as the inverse
		Fabs (1 -
	
		// Absolute difference between Demanded and Forecast
	
		Fabs (
		
			Sum (
			
				Aggr (
			
					Sum ( {&amp;lt; [Forecast Slice Date] = {"&amp;gt;$(=AddMonths ( Max ( [Forecast Slice Date] ), -24 ) )"} &amp;gt;} [Forecast Qty] ) * [Acq Cost]
					
				, [%PairKey] )
			
			)
			
			-
			
			Sum (
			
				Aggr (
			
					Sum ( [Demanded Qty] ) * [Acq Cost]
					
				, [%PairKey] )
			
			)
		)
		
		// Divided by Demand (real value that is intended to predict)
		/
		Sum (
			
				Aggr (
			
					Sum ( [Demanded Qty] ) * [Acq Cost]
					
				, [%PairKey] )
			
			)
	
	) * 100
	
	, '#.##0,00')

		&amp;amp; '%'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Any ideas?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 21:33:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Rolling-Last-24-Months-Metric-Line-Chart/m-p/2448132#M97802</guid>
      <dc:creator>paulinhok14</dc:creator>
      <dc:date>2024-05-02T21:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling Last 24 Months Metric - Line Chart</title>
      <link>https://community.qlik.com/t5/App-Development/Rolling-Last-24-Months-Metric-Line-Chart/m-p/2448140#M97803</link>
      <description>&lt;P&gt;The easiest one is to build grouping calendar. So you link in the grouping calendar MonthYear with all 24 MonthYears which should belong to rolling 24 periods. When you make a selection on one of those you should have 24 months selected in your calendar.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you use that as your dimension in the chart.&lt;/P&gt;
&lt;P&gt;cheers&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 23:21:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Rolling-Last-24-Months-Metric-Line-Chart/m-p/2448140#M97803</guid>
      <dc:creator>Lech_Miszkiewicz</dc:creator>
      <dc:date>2024-05-02T23:21:31Z</dc:date>
    </item>
  </channel>
</rss>

