<?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: This Year vs Last Year with Date Grouping in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/This-Year-vs-Last-Year-with-Date-Grouping/m-p/1829035#M68331</link>
    <description>&lt;P&gt;Hey, try this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;TABLE:
LOAD * INLINE [
OrderID, Date,	Amount
1,	29/5/2020,	10
2,	30/5/2020,	20
3,	31/5/2020,	30
5,	1/6/2019,	22
];

temp:
LOAD
NUM(min_date+iterno()-1) as date
WHILE min_date+iterno()-1 &amp;lt;= max_date;

LOAD
MIN(YEARSTART(Date)) as min_date,
MAX(Date) as max_date
RESIDENT TABLE;

temp2:
LOAD
date,
YEAR(date) as year,
1 as counter
RESIDENT temp
ORDER BY date;

DROP TABLE temp;

temp3:
LOAD
date,
IF(PREVIOUS(year)=year,RANGESUM(PEEK(counter),counter),counter) as counter
RESIDENT temp2;

DROP TABLE temp2;

INNER JOIN (temp3)
LOAD
counter,
MAX(date) AS date_corr,
1 AS max_ym_flag
RESIDENT temp3
GROUP BY counter;

[ml_month_value]:
MAPPING LOAD
NUM(date),
MONTH(date_corr)
RESIDENT temp3;

DROP TABLE temp3;

Table2:
LOAD
*,
Month(Date) as Month,
Date(Date,'MMM-YYYY') as YearMonth,
APPLYMAP('ml_month_value',NUM(Date),Month(Date)) as Month_corrected
Resident TABLE;

Drop table TABLE;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Aug 2021 12:09:45 GMT</pubDate>
    <dc:creator>RsQK</dc:creator>
    <dc:date>2021-08-17T12:09:45Z</dc:date>
    <item>
      <title>This Year vs Last Year with Date Grouping</title>
      <link>https://community.qlik.com/t5/App-Development/This-Year-vs-Last-Year-with-Date-Grouping/m-p/1828951#M68323</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Working on the Current Year vs Last year requirements but I got a request to group a certain date into the previous month it is mainly due to leap year Feb and It has a pre-defined calendar.&lt;BR /&gt;EG: 1 June 2019 should compare with 31 May 2021&lt;BR /&gt;Currently, the bar chart showing June and May.&lt;BR /&gt;Expected output the values should appear on May, is there any way recommend a solution in order to group certain date to the previous month? Every month will have a set of date grouping.&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 05:26:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/This-Year-vs-Last-Year-with-Date-Grouping/m-p/1828951#M68323</guid>
      <dc:creator>BrandonN</dc:creator>
      <dc:date>2021-08-17T05:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: This Year vs Last Year with Date Grouping</title>
      <link>https://community.qlik.com/t5/App-Development/This-Year-vs-Last-Year-with-Date-Grouping/m-p/1829035#M68331</link>
      <description>&lt;P&gt;Hey, try this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;TABLE:
LOAD * INLINE [
OrderID, Date,	Amount
1,	29/5/2020,	10
2,	30/5/2020,	20
3,	31/5/2020,	30
5,	1/6/2019,	22
];

temp:
LOAD
NUM(min_date+iterno()-1) as date
WHILE min_date+iterno()-1 &amp;lt;= max_date;

LOAD
MIN(YEARSTART(Date)) as min_date,
MAX(Date) as max_date
RESIDENT TABLE;

temp2:
LOAD
date,
YEAR(date) as year,
1 as counter
RESIDENT temp
ORDER BY date;

DROP TABLE temp;

temp3:
LOAD
date,
IF(PREVIOUS(year)=year,RANGESUM(PEEK(counter),counter),counter) as counter
RESIDENT temp2;

DROP TABLE temp2;

INNER JOIN (temp3)
LOAD
counter,
MAX(date) AS date_corr,
1 AS max_ym_flag
RESIDENT temp3
GROUP BY counter;

[ml_month_value]:
MAPPING LOAD
NUM(date),
MONTH(date_corr)
RESIDENT temp3;

DROP TABLE temp3;

Table2:
LOAD
*,
Month(Date) as Month,
Date(Date,'MMM-YYYY') as YearMonth,
APPLYMAP('ml_month_value',NUM(Date),Month(Date)) as Month_corrected
Resident TABLE;

Drop table TABLE;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 12:09:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/This-Year-vs-Last-Year-with-Date-Grouping/m-p/1829035#M68331</guid>
      <dc:creator>RsQK</dc:creator>
      <dc:date>2021-08-17T12:09:45Z</dc:date>
    </item>
  </channel>
</rss>

