<?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: Obtaining last field based on max(date) in same line in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369232#M492008</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dick&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried that solution but with nearly 2 million rows of data in the transactions table the script is taking a long time to execute. So far 30 minutes has elapsed as opposed to the usual 6 minutes and it's still not finished so I don't think this is a workable solution but thanks for your suggestion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Martina&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's worked, many thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Jul 2012 14:04:51 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-07-26T14:04:51Z</dc:date>
    <item>
      <title>Obtaining last field based on max(date) in same line</title>
      <link>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369229#M492005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm producing a report that details the last payment made by a customer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My tables are:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Customer Table: Customer ID, Customer name﻿&lt;/LI&gt;&lt;LI&gt;Transactions Table: UniqueID, Customer ID, Transaction Type, Transaction Date, Transaction Amount, Transaction Method﻿&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data I'm trying to produce is a list of customers and their last payment amount, date and method. A payment is a transaction type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've managed to obtain the last payment amount and date but am struggling to get the method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I obtained the last payment date with the below formula in the script, loading the transaction table and grouping by Customer ID&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;"(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Transaction Type&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = 'Payment'&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;, max(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;TransactionDate&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Last Payment Date]"&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-size: 10pt;"&gt;I then got the last payment amount with the following expression in the pivot table with Customer ID as my dimension. However I can see that there may be a flaw with this if 2 payments were to be received in the same day.&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&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;"sum&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;TransactionDate&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Last Payment Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Transaction Type]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;='Payment', &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;NetTransactionAmount&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;) "&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&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;So my questions are:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt;"&gt;Is there a better way of getting the last payment amount?&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt;"&gt;How do I get the last payment method? &lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 10pt;"&gt;The unique ID for transactions increases numerically in chronological order so this may be useful for a solution.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2012 10:50:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369229#M492005</guid>
      <dc:creator />
      <dc:date>2012-07-26T10:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining last field based on max(date) in same line</title>
      <link>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369230#M492006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd solve it in the script by adding a "last transaction indicator".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13433009911348773" jivemacro_uid="_13433009911348773"&gt;&lt;P&gt;JOIN (Transactions) &lt;/P&gt;&lt;P&gt;LOAD max([UniqueID],&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; 1 As LastTransaction&lt;/P&gt;&lt;P&gt;Resident Transactions&lt;/P&gt;&lt;P&gt;Group by Customer ID,&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; [Transaction Type]&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will result in a 1 in the LastTransaction column for the last transaction of each type made by the customer. All other records will have a NULL value in that column.&lt;/P&gt;&lt;P&gt;I'm assuming your UniqueID is an incremental number (so the most recent transaction has the highest UniqueID). &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2012 11:12:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369230#M492006</guid>
      <dc:creator />
      <dc:date>2012-07-26T11:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining last field based on max(date) in same line</title>
      <link>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369231#M492007</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;if you have this new field in your script created&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;"(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Transaction Type&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = 'Payment'&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;, max(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;TransactionDate&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Last Payment Date]"&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use this expression in the chart:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum({&amp;lt;[Translation Type] = {"Payment"} , TransactionDate={"$(=Only([Last Payment Date]))"}&amp;gt;} NetTransactionAmount)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings from Munich&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Martina&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2012 11:15:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369231#M492007</guid>
      <dc:creator>brenner_martina</dc:creator>
      <dc:date>2012-07-26T11:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining last field based on max(date) in same line</title>
      <link>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369232#M492008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dick&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried that solution but with nearly 2 million rows of data in the transactions table the script is taking a long time to execute. So far 30 minutes has elapsed as opposed to the usual 6 minutes and it's still not finished so I don't think this is a workable solution but thanks for your suggestion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Martina&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's worked, many thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2012 14:04:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369232#M492008</guid>
      <dc:creator />
      <dc:date>2012-07-26T14:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining last field based on max(date) in same line</title>
      <link>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369233#M492009</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 think there is something wrong, that's not normal! I thought, you just have the field Maxdate in your script entered! I gave you only a possible expression!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings from Munich&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Martina&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2012 14:18:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369233#M492009</guid>
      <dc:creator>brenner_martina</dc:creator>
      <dc:date>2012-07-26T14:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining last field based on max(date) in same line</title>
      <link>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369234#M492010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Maria,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your solution worked. My other comments were in response to dickzeeman's suggestion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2012 14:27:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369234#M492010</guid>
      <dc:creator />
      <dc:date>2012-07-26T14:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining last field based on max(date) in same line</title>
      <link>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369235#M492011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FINE!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2012 14:30:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Obtaining-last-field-based-on-max-date-in-same-line/m-p/369235#M492011</guid>
      <dc:creator>brenner_martina</dc:creator>
      <dc:date>2012-07-26T14:30:25Z</dc:date>
    </item>
  </channel>
</rss>

