<?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: Calculating Difference Between Years in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467747#M1151168</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could this be done in the script ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Load Excel File &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;two: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JOIN (one) Load &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (recno () = 1 or Product &amp;lt;&amp;gt; peek (Product), 0, Value - previous (Value)) As ValueDiff, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Product, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Year &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RESIDENT one &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ORDER BY Product, Year;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 May 2013 15:31:20 GMT</pubDate>
    <dc:creator>devans_1</dc:creator>
    <dc:date>2013-05-16T15:31:20Z</dc:date>
    <item>
      <title>Calculating Difference Between Years</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467745#M1151166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an excel table uploaded into qlikview that shows the following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 100%; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Item 1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Value&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Product 1&lt;/TD&gt;&lt;TD&gt;2010&lt;/TD&gt;&lt;TD&gt;£1.20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Product 1&lt;/TD&gt;&lt;TD&gt;2011&lt;/TD&gt;&lt;TD&gt;£1.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Product 2&lt;/TD&gt;&lt;TD&gt;2010&lt;/TD&gt;&lt;TD&gt;£1.40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Product 2&lt;/TD&gt;&lt;TD&gt;2011&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;£0.75&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Product 3&lt;/TD&gt;&lt;TD&gt;2010&lt;/TD&gt;&lt;TD&gt;£1.40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Product 3&lt;/TD&gt;&lt;TD&gt;2011&lt;/TD&gt;&lt;TD&gt;£2.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can upload this into Qlikview and produce a straight table using the year and product as dimensions and sum of value in expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I calculate and show the &lt;EM&gt;difference &lt;/EM&gt;between the years for each product &lt;EM&gt;without &lt;/EM&gt;changing the way the table is loaded from excel?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 14:45:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467745#M1151166</guid>
      <dc:creator />
      <dc:date>2013-05-16T14:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Difference Between Years</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467746#M1151167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Take a look at the above() function in the Help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 15:06:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467746#M1151167</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2013-05-16T15:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Difference Between Years</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467747#M1151168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could this be done in the script ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Load Excel File &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;two: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JOIN (one) Load &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (recno () = 1 or Product &amp;lt;&amp;gt; peek (Product), 0, Value - previous (Value)) As ValueDiff, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Product, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Year &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RESIDENT one &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ORDER BY Product, Year;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 15:31:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467747#M1151168</guid>
      <dc:creator>devans_1</dc:creator>
      <dc:date>2013-05-16T15:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Difference Between Years</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467748#M1151169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David, I tried the formula myself because I have a similar need, but QV gives an error message about being out of virtual memory and crashes. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp; Formula looked nice.&amp;nbsp; (For me it is about the 8th or 9th&amp;nbsp; resident load following a variety of other formula loads applied to the third or fourth layer of fields created in the resident loads.. so maybe QV got sucked into a blackhole trying to peek() and previous() through that stuff.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi Thomas, worst case scenario is you can put that on a pivot table, then drag the Year column from the vertical to the horizontal axis.&amp;nbsp; Then when you export to excel you can just do =e2-d2 in column F and copy it down for the difference.&amp;nbsp; (This is my present workaround.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;QlikView staff, all of the set analysis tutorials and posts I've read go as far as helping people get the two sets setup separately (by years, regions, whatever) then stop.&amp;nbsp; I've been wandering through set analysis and alternate states up to my eyeballs, but not seen something where I can make a column to compute the difference between state 1 and state 2.&amp;nbsp; It would be nice if Qlikview had an automated something similar to totals, sums, avg, and such that would give differences say:&lt;/P&gt;&lt;P&gt;=if(Value&amp;lt;&amp;gt;Null() AND Year=2012,Value) - if(Value&amp;lt;&amp;gt;Null() AND Year=2011,Value)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(To use Thomas' data)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Jun 2013 21:30:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467748#M1151169</guid>
      <dc:creator>stevelord</dc:creator>
      <dc:date>2013-06-25T21:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Difference Between Years</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467749#M1151170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would write the script similar to David, except without the join.&amp;nbsp; Create a whole new table and then drop the first.&amp;nbsp; This will be less likely to give an out of memory exception.&amp;nbsp; I imagine that the JOIN to itself may result in many records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jun 2013 00:09:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467749#M1151170</guid>
      <dc:creator />
      <dc:date>2013-06-26T00:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Difference Between Years</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467750#M1151171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. Here is what I got to work in my own script but it has an imperfect match likely due to my data structure.&amp;nbsp; I will probably go with order by UserId, TestDate and experiment with ascending/descending to hopefully make it pick the most current test date with a value in the given year.&amp;nbsp; (Sometimes folks get some tests one day and others another time in the year, so we get nulls for some tests on some dates in a given year.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Difference:&lt;/P&gt;&lt;P&gt;Load *,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (recno () = 1 or UserId &amp;lt;&amp;gt; peek (UserId), Null(), nrbBMI - previous (nrbBMI)) As cnrbBMI&lt;/P&gt;&lt;P&gt;RESIDENT RiskBanding2&lt;/P&gt;&lt;P&gt;ORDER BY UserId, TestYear;&lt;/P&gt;&lt;P&gt;Drop Table RiskBanding2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;QA Result on my data:&lt;/P&gt;&lt;P&gt;Checking one client's 2010/2011 records "manually" (exported the list of values, filtered to show only folks with values in both years and entered =f-e in Excel), I found 6828 people with BMI data in both years.&amp;nbsp; 140 of these people were not captured by the above piece of script or gave nulls where I had data.&amp;nbsp; Additionally, the script captured 10 people who only had a record in one of the two years (or maybe two records in that year given the script logic).&amp;nbsp; Lastly 3 records gave an up, down, or no change that differed from what I had on my manual process.&amp;nbsp; For all of that it is better than a 97% match to my manual results that I can probably improve with some logical finetuning.&amp;nbsp; (99.8% tolerance over here that will probably only get tighter over time. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;)&amp;nbsp; I'm not the one who can give correct answer credit, but maybe the original posting person can try the solutions on his data.&amp;nbsp; My structure isn't the cleanest and I've got 8 resident loads full of formulas built to restructure and populate missing data and/or filter garbage from millions of records on one table linked to a few others. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jun 2013 13:58:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467750#M1151171</guid>
      <dc:creator>stevelord</dc:creator>
      <dc:date>2013-06-26T13:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Difference Between Years</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467751#M1151172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As an addendum to this, yes, I was wrong to say you should use a JOIN. Not sure why I said this - bit of a slip!. As Michael says, the rest of the solution should work (as I've used it myself many times). You just create a new table with the old fields plus the new one then drop the old table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jul 2013 08:49:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Difference-Between-Years/m-p/467751#M1151172</guid>
      <dc:creator>devans_1</dc:creator>
      <dc:date>2013-07-23T08:49:35Z</dc:date>
    </item>
  </channel>
</rss>

