<?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 Find previous value based on multiple fields in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Find-previous-value-based-on-multiple-fields/m-p/20200#M3340</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Following is my query:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following stored in my qvx:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;load * inline[&lt;/P&gt;&lt;P&gt;Account, TransactionId, UniqueValue&lt;/P&gt;&lt;P&gt;1, 111, 'abc'&lt;/P&gt;&lt;P&gt;10, 120, 'bcd'&lt;/P&gt;&lt;P&gt;2, 112, 'def'&lt;/P&gt;&lt;P&gt;10, 117, 'stu'&lt;/P&gt;&lt;P&gt;2, 113, 'ghi'&lt;/P&gt;&lt;P&gt;3, 114, 'jkl'&lt;/P&gt;&lt;P&gt;3, 116, 'pqr'&lt;/P&gt;&lt;P&gt;10, 118, 'vwx'&lt;/P&gt;&lt;P&gt;3, 115, 'mno'&lt;/P&gt;&lt;P&gt;10, 119, 'yza'&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to display a table such that I get a previous value of UniqueValue coulmn based on ascending order of TransactionId sorted by Account like:&lt;/P&gt;&lt;P&gt;Account, TransactionId, UniqueValue, LastUniqueValue&lt;/P&gt;&lt;P&gt;1, 111, abc, -&lt;/P&gt;&lt;P&gt;2, 112, def, -&lt;/P&gt;&lt;P&gt;2, 113, ghi, def&lt;/P&gt;&lt;P&gt;3, 114, jkl, -&lt;/P&gt;&lt;P&gt;3, 115, mno, jkl&lt;/P&gt;&lt;P&gt;3, 116, pqr, mno&lt;/P&gt;&lt;P&gt;10, 117, stu, -&lt;/P&gt;&lt;P&gt;10, 118, vwx, stu&lt;/P&gt;&lt;P&gt;10, 119, yza, vwx&lt;/P&gt;&lt;P&gt;10, 120, bcd, yza;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know if anyone can create a script expression or a chart function to achieve this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mansi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Feb 2018 06:34:59 GMT</pubDate>
    <dc:creator>mansi_dv</dc:creator>
    <dc:date>2018-02-14T06:34:59Z</dc:date>
    <item>
      <title>Find previous value based on multiple fields</title>
      <link>https://community.qlik.com/t5/QlikView/Find-previous-value-based-on-multiple-fields/m-p/20200#M3340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Following is my query:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following stored in my qvx:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;load * inline[&lt;/P&gt;&lt;P&gt;Account, TransactionId, UniqueValue&lt;/P&gt;&lt;P&gt;1, 111, 'abc'&lt;/P&gt;&lt;P&gt;10, 120, 'bcd'&lt;/P&gt;&lt;P&gt;2, 112, 'def'&lt;/P&gt;&lt;P&gt;10, 117, 'stu'&lt;/P&gt;&lt;P&gt;2, 113, 'ghi'&lt;/P&gt;&lt;P&gt;3, 114, 'jkl'&lt;/P&gt;&lt;P&gt;3, 116, 'pqr'&lt;/P&gt;&lt;P&gt;10, 118, 'vwx'&lt;/P&gt;&lt;P&gt;3, 115, 'mno'&lt;/P&gt;&lt;P&gt;10, 119, 'yza'&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to display a table such that I get a previous value of UniqueValue coulmn based on ascending order of TransactionId sorted by Account like:&lt;/P&gt;&lt;P&gt;Account, TransactionId, UniqueValue, LastUniqueValue&lt;/P&gt;&lt;P&gt;1, 111, abc, -&lt;/P&gt;&lt;P&gt;2, 112, def, -&lt;/P&gt;&lt;P&gt;2, 113, ghi, def&lt;/P&gt;&lt;P&gt;3, 114, jkl, -&lt;/P&gt;&lt;P&gt;3, 115, mno, jkl&lt;/P&gt;&lt;P&gt;3, 116, pqr, mno&lt;/P&gt;&lt;P&gt;10, 117, stu, -&lt;/P&gt;&lt;P&gt;10, 118, vwx, stu&lt;/P&gt;&lt;P&gt;10, 119, yza, vwx&lt;/P&gt;&lt;P&gt;10, 120, bcd, yza;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know if anyone can create a script expression or a chart function to achieve this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mansi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Feb 2018 06:34:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Find-previous-value-based-on-multiple-fields/m-p/20200#M3340</guid>
      <dc:creator>mansi_dv</dc:creator>
      <dc:date>2018-02-14T06:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Find previous value based on multiple fields</title>
      <link>https://community.qlik.com/t5/QlikView/Find-previous-value-based-on-multiple-fields/m-p/20201#M3341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use an interecord-function like &lt;A href="https://community.qlik.com/docs/DOC-9314"&gt;Peek() or Previous() ?&lt;/A&gt; for it in a properly sorted resident load, maybe like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *, if(Account = previous(Account), previous(UniqueValue)) as LastUniqueValue&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;resident&lt;/STRONG&gt; Source &lt;STRONG&gt;order by Account, TransactionId&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Feb 2018 12:29:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Find-previous-value-based-on-multiple-fields/m-p/20201#M3341</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2018-02-14T12:29:36Z</dc:date>
    </item>
  </channel>
</rss>

