<?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: AddMonths Function in Load Script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1603877#M444558</link>
    <description>&lt;P&gt;So, all you want it to find the 6 Month Ago, 12 Month Ago, 18 Months Ago, and 24 Months Ago from your PeriodDate field for all Account? Can you have more than one Account with different PeriodDates? In this case you would want to go 6, 12, 18, 24 Month back from the max date?&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2019 18:35:54 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2019-07-18T18:35:54Z</dc:date>
    <item>
      <title>AddMonths Function in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1603868#M444557</link>
      <description>&lt;P&gt;I have a dataset file, but I want to add a calculated column to the dataset, based on the max date field present in the entire dataset.&lt;/P&gt;&lt;P&gt;I have brought in the data, and have gotten the max(date field). Now, I want to add my calculated &lt;STRONG&gt;&lt;EM&gt;periodkey&lt;/EM&gt; &lt;/STRONG&gt;field to the dataset and don't know how to do this.&lt;/P&gt;&lt;P&gt;on the front end, I am able to derive this value using AddMonths() function, but I want this to be included in the script, so each Account will have a corresponding &lt;EM&gt;&lt;STRONG&gt;periodkey&lt;/STRONG&gt; &lt;/EM&gt;in the final table. (not trying to sum anything up).&lt;/P&gt;&lt;P&gt;Current Script:&lt;/P&gt;&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif" size="2" color="#000000"&gt;BlacklineFileTemp:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif" size="2" color="#000000"&gt;LOAD Account, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif" size="2" color="#000000"&gt;[Item Amount] as Amount, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif" size="2" color="#000000"&gt;PeriodDate&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif" size="2" color="#000000"&gt;FROM TestBlackline.xlsx (ooxml, embedded labels);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif" size="2" color="#000000"&gt;Temp:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif" size="2" color="#000000"&gt;LOAD&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif" size="2" color="#000000"&gt;DATE(MAX(PeriodDate)) AS MaxPeriodDate&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif" size="2" color="#000000"&gt;RESIDENT BlacklineFileTemp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;(i have attached a copy of the dataset and QVW file). thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 20:25:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1603868#M444557</guid>
      <dc:creator>triekong</dc:creator>
      <dc:date>2024-11-16T20:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: AddMonths Function in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1603877#M444558</link>
      <description>&lt;P&gt;So, all you want it to find the 6 Month Ago, 12 Month Ago, 18 Months Ago, and 24 Months Ago from your PeriodDate field for all Account? Can you have more than one Account with different PeriodDates? In this case you would want to go 6, 12, 18, 24 Month back from the max date?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 18:35:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1603877#M444558</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-07-18T18:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: AddMonths Function in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1603888#M444560</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46628"&gt;@sunny_talwar&lt;/a&gt;&amp;nbsp;yes. i want to find the&lt;SPAN&gt;&amp;nbsp;6 Month Ago, 12 Month Ago, 18 Months Ago, and 24 Months Ago but from the most recent &lt;EM&gt;PeriodDate&lt;/EM&gt; field in the entire dataset, which is given by the Max(&lt;EM&gt;PeriodDate&lt;/EM&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 account can never have more than 1 &lt;EM&gt;PeriodDate&lt;/EM&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;does this explain it better?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 18:52:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1603888#M444560</guid>
      <dc:creator>triekong</dc:creator>
      <dc:date>2019-07-18T18:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: AddMonths Function in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1603890#M444562</link>
      <description>&lt;P&gt;But you mentioned that you wanted these new dates for each account?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 18:54:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1603890#M444562</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-07-18T18:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: AddMonths Function in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1603918#M444565</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46628"&gt;@sunny_talwar&lt;/a&gt;&amp;nbsp; no problem. let me explain better.&lt;/P&gt;&lt;P&gt;so for every account, there is 1 &lt;STRONG&gt;&lt;EM&gt;PeriodDate&lt;/EM&gt;&lt;/STRONG&gt;. and for each periodDate, I want 1 PeriodKey.&lt;/P&gt;&lt;P&gt;Based on the most recent &lt;STRONG&gt;&lt;EM&gt;PeriodDate&lt;/EM&gt; &lt;/STRONG&gt;in the entire dataset, I want to include a new column, called "&lt;STRONG&gt;&lt;EM&gt;PeriodKey&lt;/EM&gt;&lt;/STRONG&gt;". this will depend on if the Account's &lt;STRONG&gt;&lt;I&gt;PeriodDate &lt;/I&gt;&lt;/STRONG&gt;was&amp;nbsp;between 6months ago, 12months ago, 18months ago or 24months ago, from the Most Recent Date of the entire dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;so for example, if my &lt;STRONG&gt;&lt;EM&gt;MaxPeriodDate&lt;/EM&gt; &lt;/STRONG&gt;is "&lt;EM&gt;02/28/2019&lt;/EM&gt;", and i have an account with the date of "&lt;EM&gt;12/31/2018&lt;/EM&gt;", (this is 3months prior to the most recent PeriodDate), so it happened within the last 6months.&lt;/P&gt;&lt;P&gt;this Account should now have a &lt;EM&gt;&lt;STRONG&gt;P&lt;/STRONG&gt;&lt;STRONG&gt;&lt;EM&gt;e&lt;/EM&gt;riodKey &lt;/STRONG&gt;&lt;/EM&gt;of 1. so the new column to be created in the end result dataset, should look like this:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Account&lt;/TD&gt;&lt;TD&gt;Amount&lt;/TD&gt;&lt;TD&gt;PeriodDate&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;PeriodKey&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;$$$&lt;/TD&gt;&lt;TD&gt;12/31/2018&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;$$$&lt;/TD&gt;&lt;TD&gt;2/28/2019&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;$$$&lt;/TD&gt;&lt;TD&gt;5/30/2018&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The logic for the periodkey is in the script on the attached file&lt;/P&gt;&lt;P&gt;if 0-6months ago --&amp;gt;periodKey 1, if 7-12months&amp;nbsp;ago --&amp;gt;periodKey 2, if 13-18months ago --&amp;gt;periodKey 3, if 19-24months&amp;nbsp;ago --&amp;gt; periodKey 4&lt;/P&gt;&lt;P&gt;what i need help with, is how to include this calculation in the load script and create the column&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 19:44:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1603918#M444565</guid>
      <dc:creator>triekong</dc:creator>
      <dc:date>2019-07-18T19:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: AddMonths Function in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1604165#M444576</link>
      <description>&lt;P&gt;May be try this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;BlacklineFileTemp:
LOAD Account, 
	[Item Amount] as Amount, 
	PeriodDate
FROM TestBlackline.xlsx
(ooxml, embedded labels);

Left Join (BlacklineFileTemp)
LOAD Max(PeriodDate) as MaxPeriodDate
Resident BlacklineFileTemp;

BlacklineFile:
LOAD *,
	 If(PeriodDate &amp;gt;= AddMonths(MaxPeriodDate, -6) and PeriodDate &amp;lt;= AddMonths(MaxPeriodDate, 0), 1,
	 If(PeriodDate &amp;gt;= AddMonths(MaxPeriodDate, -12) and PeriodDate &amp;lt; AddMonths(MaxPeriodDate, -6), 2,
	 If(PeriodDate &amp;gt;= AddMonths(MaxPeriodDate, -18) and PeriodDate &amp;lt; AddMonths(MaxPeriodDate, -12), 3,
	 If(PeriodDate &amp;gt;= AddMonths(MaxPeriodDate, -24) and PeriodDate &amp;lt; AddMonths(MaxPeriodDate, -18), 4)))) as periodkey
Resident BlacklineFileTemp;

DROP Table BlacklineFileTemp;

PeriodMapping:
LOAD * INLINE [
    periodkey, Period
    1, Mon 0-6 
    2, Mon 7-12 
    3, Mon 13-18 
    4, Mon 19-24 
];&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 19 Jul 2019 13:20:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1604165#M444576</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-07-19T13:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: AddMonths Function in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1612466#M445241</link>
      <description>&lt;P&gt;Ekong, did Sunny's latest post with sample app get you what you needed?&amp;nbsp; If so, please be sure to give credit by clicking the Accept as Solution button on that post...&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you still need further help, leave an update.&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Brett&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 14:13:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-Function-in-Load-Script/m-p/1612466#M445241</guid>
      <dc:creator>Brett_Bleess</dc:creator>
      <dc:date>2019-08-14T14:13:16Z</dc:date>
    </item>
  </channel>
</rss>

