<?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 Getting the Previous Contract’s Date and Amount in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Getting-the-Previous-Contract-s-Date-and-Amount/m-p/2538653#M108978</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I’m trying to figure out how to pull the previous contract’s details from a master table. Here’s the setup:&lt;/P&gt;&lt;P&gt;CustomerID, ContractID, TransDate, Disbursed Amount&lt;/P&gt;&lt;P&gt;Every time a contract is completed, a new ContractID is created. What I need is:&lt;/P&gt;&lt;P&gt;For any current contract, get the date and amount of the previous contract.&lt;/P&gt;&lt;P&gt;If a customer has multiple past contracts, I only want the most recent one before the current contract.&lt;/P&gt;&lt;P&gt;I’d love to see how you’d approach it, either in the script or using chart expressions. Any tips, examples, or best practices would be great.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 09 Dec 2025 14:49:21 GMT</pubDate>
    <dc:creator>LoKi_asterix</dc:creator>
    <dc:date>2025-12-09T14:49:21Z</dc:date>
    <item>
      <title>Getting the Previous Contract’s Date and Amount</title>
      <link>https://community.qlik.com/t5/App-Development/Getting-the-Previous-Contract-s-Date-and-Amount/m-p/2538653#M108978</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I’m trying to figure out how to pull the previous contract’s details from a master table. Here’s the setup:&lt;/P&gt;&lt;P&gt;CustomerID, ContractID, TransDate, Disbursed Amount&lt;/P&gt;&lt;P&gt;Every time a contract is completed, a new ContractID is created. What I need is:&lt;/P&gt;&lt;P&gt;For any current contract, get the date and amount of the previous contract.&lt;/P&gt;&lt;P&gt;If a customer has multiple past contracts, I only want the most recent one before the current contract.&lt;/P&gt;&lt;P&gt;I’d love to see how you’d approach it, either in the script or using chart expressions. Any tips, examples, or best practices would be great.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Dec 2025 14:49:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Getting-the-Previous-Contract-s-Date-and-Amount/m-p/2538653#M108978</guid>
      <dc:creator>LoKi_asterix</dc:creator>
      <dc:date>2025-12-09T14:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the Previous Contract’s Date and Amount</title>
      <link>https://community.qlik.com/t5/App-Development/Getting-the-Previous-Contract-s-Date-and-Amount/m-p/2538678#M108979</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/31892"&gt;@LoKi_asterix&lt;/a&gt;, one possible option is this script, that create a couple of new fields with the desired data using&amp;nbsp;very common&amp;nbsp; peek and previous&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/sense/November2025/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/InterRecordFunctions/inter-record-functions-charts.htm" target="_self"&gt;inter record functions&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script:&lt;/P&gt;&lt;DIV&gt;Data:&amp;nbsp; ///some test data&lt;/DIV&gt;&lt;DIV&gt;Load * INLINE [&lt;/DIV&gt;&lt;DIV&gt;CustomerID, ContractID, TransDate, Amount&lt;/DIV&gt;&lt;DIV&gt;1, 1, 31-10-2025, 100&lt;/DIV&gt;&lt;DIV&gt;2, 1, 31-10-2025, 200&lt;/DIV&gt;&lt;DIV&gt;3, 1, 31-10-2025, 100&lt;/DIV&gt;&lt;DIV&gt;4, 1, 31-10-2025, 80&lt;/DIV&gt;&lt;DIV&gt;5, 1, 31-10-2025, 90&lt;/DIV&gt;&lt;DIV&gt;1, 2, 01-11-2025, 100&lt;/DIV&gt;&lt;DIV&gt;];&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Load&amp;nbsp; &amp;nbsp; // here using previous value to compare&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CustomerID,&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;ContractID,&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;TransDate,&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Amount,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if(CustomerID = previous(CustomerID) and TransDate &amp;gt; previous(TransDate),&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; previous(TransDate)) as Previous_TransDate,&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if(CustomerID = previous(CustomerID) and TransDate &amp;gt; previous(TransDate),&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Previous(Amount)) as Previous_Amount&amp;nbsp; &amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Resident Data&lt;/DIV&gt;&lt;DIV&gt;Order By&amp;nbsp; &amp;nbsp;// order of fields and their data is very important to make inter record treatments&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CustomerID,&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;TransDate;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;drop table Data;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;exit script;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;And this is the resulting table :&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="QFabian_0-1765294552439.png" style="width: 745px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/185660iD3F8CC16685C15BA/image-dimensions/745x498?v=v2" width="745" height="498" role="button" title="QFabian_0-1765294552439.png" alt="QFabian_0-1765294552439.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Dec 2025 15:38:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Getting-the-Previous-Contract-s-Date-and-Amount/m-p/2538678#M108979</guid>
      <dc:creator>QFabian</dc:creator>
      <dc:date>2025-12-09T15:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the Previous Contract’s Date and Amount</title>
      <link>https://community.qlik.com/t5/App-Development/Getting-the-Previous-Contract-s-Date-and-Amount/m-p/2538713#M108983</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/31892"&gt;@LoKi_asterix&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The suggested solution by &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/121051"&gt;@QFabian&lt;/a&gt;&amp;nbsp;is pretty much in line with how I would solve this as well.&lt;/P&gt;&lt;P&gt;I suggest you give it a try, and accepy the suggestion as a solution if it turned out to fit your needs, or add a new comment here if it is not what you are looking for.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Dec 2025 22:34:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Getting-the-Previous-Contract-s-Date-and-Amount/m-p/2538713#M108983</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2025-12-09T22:34:53Z</dc:date>
    </item>
  </channel>
</rss>

