<?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: Identify date of previous transaction prior to defined date in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1661044#M448774</link>
    <description>&lt;P&gt;Thanks, Brett.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached a sample QVW. I have commented where the solution above has been applied in the load script. This does return the previous sales date to each transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, what I am trying to return is the previous sales date to the [First Sales Date Last 3 Years]. I hope this helps to clarify the request.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Dec 2019 15:10:42 GMT</pubDate>
    <dc:creator>Qlik_ULG</dc:creator>
    <dc:date>2019-12-27T15:10:42Z</dc:date>
    <item>
      <title>Identify date of previous transaction prior to defined date</title>
      <link>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1659165#M448597</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an issue related to dates that I am trying to resolve. Basically, I have a list of products and each sale of the product has a sales date for the transaction. I am carrying out analysis on new products sold.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A new product is defined in 2 ways:&lt;/P&gt;&lt;P&gt;- Any product whose first sales date is in the last 3 years.&lt;/P&gt;&lt;P&gt;- Any product whose first sales date for transactions within the last 3 years is greater than 5 years after the previous sales date for that product.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Identifying based on the first criteria is straightforward, through taking the Min(sales_date) and grouping by Product.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the second criteria has proven to be a challenge. I started by getting the first sales date of all products, based on sales dates in the last 3 years only. I then need to be able to get the previous sales date related to the last transaction prior to this for the given product, which obviously won't be in the last 3 years.&lt;/P&gt;&lt;P&gt;As of yet, I have been unable to return this date using various functions.&lt;/P&gt;&lt;P&gt;Once I have that date, I'll simply be measuring the gap between both, to define whether the product counts as new or not.&lt;/P&gt;&lt;P&gt;This is all being done in the load script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, the product below has 3 transactions. The first sales date is&amp;nbsp;13/04/2010. It's first sales date within the last 3 years is&amp;nbsp;23/08/2018. The previous sales date to this is 28/06/2010, so this would be categorised as a new product, given that the previous sales date is greater than 5 years before the first sales date within the last 3 years.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Product ID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Transaction ID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Sales Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;482746&lt;/TD&gt;&lt;TD&gt;437884935&lt;/TD&gt;&lt;TD&gt;13/04/2010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;482746&lt;/TD&gt;&lt;TD&gt;488654422&lt;/TD&gt;&lt;TD&gt;25/06/2010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;482746&lt;/TD&gt;&lt;TD&gt;489362743&lt;/TD&gt;&lt;TD&gt;28/06/2010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;482746&lt;/TD&gt;&lt;TD&gt;638754332&lt;/TD&gt;&lt;TD&gt;23/08/2018&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;482746&lt;/TD&gt;&lt;TD&gt;812564333&lt;/TD&gt;&lt;TD&gt;05/10/2019&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;482746&lt;/TD&gt;&lt;TD&gt;819463724&lt;/TD&gt;&lt;TD&gt;12/10/2019&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;482746&lt;/TD&gt;&lt;TD&gt;838823747&lt;/TD&gt;&lt;TD&gt;17/12/2019&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any assistance with how to define the previous sales date (in this case&amp;nbsp;28/06/2010), would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 01:39:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1659165#M448597</guid>
      <dc:creator>Qlik_ULG</dc:creator>
      <dc:date>2024-11-16T01:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Identify date of previous transaction prior to defined date</title>
      <link>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1659282#M448604</link>
      <description>&lt;P&gt;Maybe this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RAW:
LOAD [Product ID], 
[Transaction ID], 
[Sales Date]
FROM YOUR_SAMPLE_DATA;

RAW_SORT:
NoConcatenate
LOAD *
Resident RAW
Order by [Product ID] ASC, [Sales Date] ASC;
drop table RAW;

FINAL:
NoConcatenate
LOAD [Product ID], 
[Transaction ID], 
[Sales Date],
if([Product ID] = peek([Product ID]) , previous([Sales Date])) as LAST_SALES_DATE 
Resident RAW_SORT
;

drop table RAW_SORT;&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 19 Dec 2019 08:50:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1659282#M448604</guid>
      <dc:creator>zhadrakas</dc:creator>
      <dc:date>2019-12-19T08:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Identify date of previous transaction prior to defined date</title>
      <link>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1659857#M448659</link>
      <description>&lt;P&gt;Thank you very much for the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your solution does provide the previous Sales Date to each transaction. However, I have been unable to structure it to only return the previous sales date to the 'F&lt;SPAN&gt;irst Sales Date within the last 3 years'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is simply created by taking the minimum Sales Date where the within the last 3 years and grouping by Product ID and is joined into the same table, so I essentially have:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[Product ID],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[Transaction ID], &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[Sales Date],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[First Sales Date Last 3 Years]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is the Sales Date prior to this final date that I'm struggling to retrieve.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to add where&amp;nbsp;[Sales Date]=&lt;SPAN&gt;[First Sales Date Last 3 Years] to your last table, but this didn't return a value. Is there a modification&amp;nbsp;i can apply that would return the previous Sales Date to this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks again.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 16:05:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1659857#M448659</guid>
      <dc:creator>Qlik_ULG</dc:creator>
      <dc:date>2019-12-20T16:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Identify date of previous transaction prior to defined date</title>
      <link>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1660314#M448703</link>
      <description>&lt;P&gt;You may want to consider posting what you have in the QVW or post a sample such that folks can see the data model etc., this is generally what it takes on these more complex posts to get further potential solutions.&amp;nbsp; There is too much left to the imagination without it...&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Brett&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 20:45:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1660314#M448703</guid>
      <dc:creator>Brett_Bleess</dc:creator>
      <dc:date>2019-12-23T20:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Identify date of previous transaction prior to defined date</title>
      <link>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1661044#M448774</link>
      <description>&lt;P&gt;Thanks, Brett.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached a sample QVW. I have commented where the solution above has been applied in the load script. This does return the previous sales date to each transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, what I am trying to return is the previous sales date to the [First Sales Date Last 3 Years]. I hope this helps to clarify the request.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Dec 2019 15:10:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1661044#M448774</guid>
      <dc:creator>Qlik_ULG</dc:creator>
      <dc:date>2019-12-27T15:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Identify date of previous transaction prior to defined date</title>
      <link>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1662362#M448926</link>
      <description>&lt;P&gt;Having thought about this in more detail, I realise there is a more straightforward solution to the issue I outlined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I'm simply looking for the transaction and date immediately prior to the first within the last years, I simply need to pull the max from the period prior to the last 3 years. This provides what I need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for the assistance.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 10:26:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Identify-date-of-previous-transaction-prior-to-defined-date/m-p/1662362#M448926</guid>
      <dc:creator>Qlik_ULG</dc:creator>
      <dc:date>2020-01-03T10:26:11Z</dc:date>
    </item>
  </channel>
</rss>

