<?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 Re: Correlation using user specified # of recent observations in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Correlation-using-user-specified-of-recent-observations/m-p/1239610#M393836</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was using date for "most recent", so I'll need to switch to row number, plus set analysis "can't" be sensitive to the dimensions of a table, so can't directly be used to pick the correct row numbers, so I'll need to come up with something different for that reason as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm thinking the right approach would be a script change to assign a reverse of the row numbers, the most recent being 1 and then incrementing going back in time for each combination. Easily done with a second load with an order by and using the previous() function to see if we need to start our count over, and to keep track of our count. Then we can go ahead and use set analysis for performance, and the set analysis would be simple. This assumes that which records count as the "most recent 100" shouldn't change based on selections, but that was my assumption with the previous solution too. So that's my suggestion, then, and it isn't something I can test since I can't read your databases. I can still give it a shot if you need, write some untested code, but maybe what I've written in this paragraph is enough to get you on track.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: peek() function to keep track of the count, previous() refers to the input table, peek() to the output table&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Nov 2016 16:52:20 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2016-11-29T16:52:20Z</dc:date>
    <item>
      <title>Correlation using user specified # of recent observations</title>
      <link>https://community.qlik.com/t5/QlikView/Correlation-using-user-specified-of-recent-observations/m-p/1239606#M393832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to create a chart expression for a pivot table that calcs the correlations between 2 columns based on the # of observations input by the user, ie: what is the correlations based on the most recent 200 observations. The attached qvw has some sample data and an input box already built. The correlation should be based on the columns LogReturn_1 &amp;amp; LogReturn_2 for each combination of IndexShortName_1 &amp;amp; IndexShortName_2. I have tried using RangeCorrel and saw several examples using the Count(),Top(),Above() but I am not getting any results.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Nov 2016 18:18:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Correlation-using-user-specified-of-recent-observations/m-p/1239606#M393832</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-28T18:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation using user specified # of recent observations</title>
      <link>https://community.qlik.com/t5/QlikView/Correlation-using-user-specified-of-recent-observations/m-p/1239607#M393833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #575757; font-size: 10pt; font-family: arial,helvetica,sans-serif;"&gt;This seems to work:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: courier new,courier;"&gt;correl&lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;({1&amp;lt;&lt;SPAN style="color: #800000;"&gt;EquityIndex_HistReturnsCorrel.ValueDate&lt;/SPAN&gt;={&lt;SPAN style="color: #800000;"&gt;"&amp;gt;=$(=date(firstsortedvalue({1} EquityIndex_HistReturnsCorrel.ValueDate,-EquityIndex_HistReturnsCorrel.ValueDate,vCorrelationDays),'DD/MM/YYYY h:mm:ss TT'))"&lt;/SPAN&gt;}&amp;gt;} &lt;SPAN style="color: #800000;"&gt;EquityIndex_HistReturnsCorrel.LogReturn_1&lt;/SPAN&gt;,&lt;SPAN style="color: #800000;"&gt;EquityIndex_HistReturnsCorrel.LogReturn_2&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2016 01:05:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Correlation-using-user-specified-of-recent-observations/m-p/1239607#M393833</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2016-11-29T01:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation using user specified # of recent observations</title>
      <link>https://community.qlik.com/t5/QlikView/Correlation-using-user-specified-of-recent-observations/m-p/1239608#M393834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much John. I will give this a try.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2016 12:10:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Correlation-using-user-specified-of-recent-observations/m-p/1239608#M393834</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-29T12:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation using user specified # of recent observations</title>
      <link>https://community.qlik.com/t5/QlikView/Correlation-using-user-specified-of-recent-observations/m-p/1239609#M393835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the expression and I am not getting any results...In my mind, this is how I thought the calc should go:&lt;/P&gt;&lt;P&gt;1. Each row in the table has a RowNum goes from 2 to whatever the max row number is for each combo of IndexShortName_1 &amp;amp; IndexShortName_2&lt;/P&gt;&lt;P&gt;2. The user specifies how many "rows" of recent observations they want to use for the correlation calc&lt;/P&gt;&lt;P&gt;3. The expression should filter from each combo of IndexShortName_1 &amp;amp; IndexShortName_2 all of the rows where the RowNum &amp;gt;= Max(RowNum) for the combo minus the vCorrelationDays&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ie: For SPX|NKY the max row num is 11206 and if the vCorrelationDays is 100 then the correlation calc should use rows 11106 to 11206 inclusive. Another combo may have a different max rows value but should still use the most recent 100 days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I attached another qvw that has all of the combos.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2016 13:22:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Correlation-using-user-specified-of-recent-observations/m-p/1239609#M393835</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-29T13:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation using user specified # of recent observations</title>
      <link>https://community.qlik.com/t5/QlikView/Correlation-using-user-specified-of-recent-observations/m-p/1239610#M393836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was using date for "most recent", so I'll need to switch to row number, plus set analysis "can't" be sensitive to the dimensions of a table, so can't directly be used to pick the correct row numbers, so I'll need to come up with something different for that reason as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm thinking the right approach would be a script change to assign a reverse of the row numbers, the most recent being 1 and then incrementing going back in time for each combination. Easily done with a second load with an order by and using the previous() function to see if we need to start our count over, and to keep track of our count. Then we can go ahead and use set analysis for performance, and the set analysis would be simple. This assumes that which records count as the "most recent 100" shouldn't change based on selections, but that was my assumption with the previous solution too. So that's my suggestion, then, and it isn't something I can test since I can't read your databases. I can still give it a shot if you need, write some untested code, but maybe what I've written in this paragraph is enough to get you on track.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: peek() function to keep track of the count, previous() refers to the input table, peek() to the output table&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2016 16:52:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Correlation-using-user-specified-of-recent-observations/m-p/1239610#M393836</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2016-11-29T16:52:20Z</dc:date>
    </item>
  </channel>
</rss>

