<?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 PEEK function in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/PEEK-function/m-p/595692#M220671</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not very good with peek-formula, so I would need some help.&lt;/P&gt;&lt;P&gt; I have a table in where I have all sales forecasts, budgets and demandplans in same table. I know how to write the where clause that I can limit my load only for this years budget, but how about the latest forecast and last and previous demand plan?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Plan&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Version&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Sales&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;F&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;F&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;D&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;D&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;B= budget&lt;/P&gt;&lt;P&gt;F=forecast&lt;/P&gt;&lt;P&gt;D=demand plan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an example above. When I want to compare actuals to budget, I need to compare actuals to first row and that I can limit by saing when B then only the current year. When I would like to compare actuals to forecast I would need to have the current year and the latest version (in this case version 4); how can I write the forecast limit so that only the latest is taken into account? Same thing with demand plan, but I would need to have also the previous plan (so called N-1); how can I do that? What script I need to write that I see the current demand plan as D, 2014, version 3 and the N-1 plan as D, 2014, version 3?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Janne&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Feb 2014 13:53:35 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-02-17T13:53:35Z</dc:date>
    <item>
      <title>PEEK function</title>
      <link>https://community.qlik.com/t5/QlikView/PEEK-function/m-p/595692#M220671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not very good with peek-formula, so I would need some help.&lt;/P&gt;&lt;P&gt; I have a table in where I have all sales forecasts, budgets and demandplans in same table. I know how to write the where clause that I can limit my load only for this years budget, but how about the latest forecast and last and previous demand plan?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Plan&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Version&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Sales&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;F&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;F&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;D&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;D&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;B= budget&lt;/P&gt;&lt;P&gt;F=forecast&lt;/P&gt;&lt;P&gt;D=demand plan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an example above. When I want to compare actuals to budget, I need to compare actuals to first row and that I can limit by saing when B then only the current year. When I would like to compare actuals to forecast I would need to have the current year and the latest version (in this case version 4); how can I write the forecast limit so that only the latest is taken into account? Same thing with demand plan, but I would need to have also the previous plan (so called N-1); how can I do that? What script I need to write that I see the current demand plan as D, 2014, version 3 and the N-1 plan as D, 2014, version 3?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Janne&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 13:53:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/PEEK-function/m-p/595692#M220671</guid>
      <dc:creator />
      <dc:date>2014-02-17T13:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: PEEK function</title>
      <link>https://community.qlik.com/t5/QlikView/PEEK-function/m-p/595693#M220672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Janne,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you need only the latest version of the forecast, but the latest and the one before of the demand_plan,&lt;/P&gt;&lt;P&gt;then you can't do it in one LOAD statement - well, you could by using a rather complex IF_construct, but I'd suggest otherwise - to keep it simple and easy_to_understand for others, should you not be there.&lt;/P&gt;&lt;P&gt;=&amp;gt; Try implementing in the LOAD an aggregation (GROUP BY) and a max() function,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; combined with a SORT BY (do it in two steps for the reason stated above) (max(version) is an aggregation function and requires that you use a GROUP BY clause encompassing all other (non-aggregated) field.&lt;/P&gt;&lt;P&gt;=&amp;gt; By sorting in a way so that all the lines with the same letter will be in one block, you use max() to load the one with the largest version_nr. and finally, with a WHERE... clause (at the end of the LOAD) you filter for all the letters except D (for the demand plan, you have to use a modified max() formula to load the largest and second-largest version_nr.&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 14:01:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/PEEK-function/m-p/595693#M220672</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2014-02-17T14:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: PEEK function</title>
      <link>https://community.qlik.com/t5/QlikView/PEEK-function/m-p/595694#M220673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could load the data into separate columns in the load script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(Plan='B', Sales as Sales_Budget,&lt;/P&gt;&lt;P&gt;if(Plan='F', Sales as Sales_Forecast,&lt;/P&gt;&lt;P&gt;if(Plan='D', Sales as Sales_Demand,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can simply sum the columns to get the values you want, and do comparisons between values to get the variance.&lt;/P&gt;&lt;P&gt;e.g.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(Sales_Demand - Sales_Forecast)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({&amp;lt;Year={2014}&amp;gt;} Sales_Budget)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; will give the figures for the current year.&lt;/P&gt;&lt;P&gt;sum({&amp;lt;Year={2013}&amp;gt;} Sales_Budget)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; will give the figures for the&amp;nbsp; last year.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 14:03:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/PEEK-function/m-p/595694#M220673</guid>
      <dc:creator>Colin-Albert</dc:creator>
      <dc:date>2014-02-17T14:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: PEEK function</title>
      <link>https://community.qlik.com/t5/QlikView/PEEK-function/m-p/595695#M220674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I use the extract same approach data nibbler &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 14:06:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/PEEK-function/m-p/595695#M220674</guid>
      <dc:creator />
      <dc:date>2014-02-17T14:06:59Z</dc:date>
    </item>
  </channel>
</rss>

