<?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: Take the latest data for a particular month in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Take-the-latest-data-for-a-particular-month/m-p/1659924#M448666</link>
    <description>&lt;P&gt;First, I would store the latest year in a variable:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Temp_maxYear:
LOAD max(Year) as maxYear
Resident TableA;

Let vMaxYear = Peek('maxYear');
Drop Table Temp_maxYear;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I would add another Where clause to the TableB load:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TableB:
load Category,
Brand,
Quantity,
Month,
Year+1 as Year,
YearMonth
resident TableA
where Month=12
and Year = '$(vMaxYear)';&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 20 Dec 2019 23:46:19 GMT</pubDate>
    <dc:creator>gavinlaird</dc:creator>
    <dc:date>2019-12-20T23:46:19Z</dc:date>
    <item>
      <title>Take the latest data for a particular month</title>
      <link>https://community.qlik.com/t5/QlikView/Take-the-latest-data-for-a-particular-month/m-p/1659899#M448663</link>
      <description>&lt;P&gt;I have the below table.&lt;/P&gt;&lt;P&gt;TableA:&lt;BR /&gt;LOAD * INLINE[&lt;BR /&gt;Category, Brand, Quantity, Month, Year, YearMonth&lt;BR /&gt;Electronics, LG, 20, 8, 2018, 2018-08&lt;BR /&gt;Electronics, LG, 30, 12, 2018, 2018-12&lt;BR /&gt;Electronics, LG, 40, 4, 2019, 2019-04&lt;BR /&gt;Electronics, LG, 50, 12, 2019, 2019-12&lt;/P&gt;&lt;P&gt;DRINKS, COKE, 20, 12, 2017, 2017-12&lt;BR /&gt;DRINKS, COKE, 20, 12, 2018, 2018-12&lt;BR /&gt;FRUITS, APPLE, 25, 12, 2018, 2018-12];&lt;/P&gt;&lt;P&gt;I want the data for Month =12 and latest year for each Category and Brand&amp;nbsp; like below in a different table.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Brand&lt;/TD&gt;&lt;TD&gt;Category&lt;/TD&gt;&lt;TD&gt;Month&lt;/TD&gt;&lt;TD&gt;Quantity&lt;/TD&gt;&lt;TD&gt;Year&lt;/TD&gt;&lt;TD&gt;YearMonth&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;LG&lt;/TD&gt;&lt;TD&gt;Electronics&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;2019-12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;COKE&lt;/TD&gt;&lt;TD&gt;DRINKS&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;2018&lt;/TD&gt;&lt;TD&gt;2018-12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;APPLE&lt;/TD&gt;&lt;TD&gt;FRUITS&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;2018&lt;/TD&gt;&lt;TD&gt;2018-12&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I'm getting data for both the year 2018 and 2019 like below.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Brand&lt;/TD&gt;&lt;TD&gt;Category&lt;/TD&gt;&lt;TD&gt;Month&lt;/TD&gt;&lt;TD&gt;Quantity&lt;/TD&gt;&lt;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;&lt;P&gt;Quantity,&lt;/P&gt;&lt;P&gt;Month,&lt;/P&gt;&lt;P&gt;Year+1 as Year,&lt;/P&gt;&lt;P&gt;YearMonth&lt;/P&gt;&lt;P&gt;resident TableA&lt;/P&gt;&lt;P&gt;where Month=12;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please suggest. test file is attached.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 01:38:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Take-the-latest-data-for-a-particular-month/m-p/1659899#M448663</guid>
      <dc:creator>safik003</dc:creator>
      <dc:date>2024-11-16T01:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Take the latest data for a particular month</title>
      <link>https://community.qlik.com/t5/QlikView/Take-the-latest-data-for-a-particular-month/m-p/1659924#M448666</link>
      <description>&lt;P&gt;First, I would store the latest year in a variable:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Temp_maxYear:
LOAD max(Year) as maxYear
Resident TableA;

Let vMaxYear = Peek('maxYear');
Drop Table Temp_maxYear;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I would add another Where clause to the TableB load:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TableB:
load Category,
Brand,
Quantity,
Month,
Year+1 as Year,
YearMonth
resident TableA
where Month=12
and Year = '$(vMaxYear)';&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 20 Dec 2019 23:46:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Take-the-latest-data-for-a-particular-month/m-p/1659924#M448666</guid>
      <dc:creator>gavinlaird</dc:creator>
      <dc:date>2019-12-20T23:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: Take the latest data for a particular month</title>
      <link>https://community.qlik.com/t5/QlikView/Take-the-latest-data-for-a-particular-month/m-p/1659930#M448669</link>
      <description>&lt;P&gt;Thanks for your response. It's perfectly working when there is one Category and one Brand with max year as 2019. But problem is arising when there is multiple Category and Brand with different max year for each Category and Brand. I have modified my question accordingly. Please check and suggest&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2019 04:02:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Take-the-latest-data-for-a-particular-month/m-p/1659930#M448669</guid>
      <dc:creator>safik003</dc:creator>
      <dc:date>2019-12-21T04:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Take the latest data for a particular month</title>
      <link>https://community.qlik.com/t5/QlikView/Take-the-latest-data-for-a-particular-month/m-p/1659932#M448670</link>
      <description>&lt;P&gt;I'm sorry that I've haven't got a qv desktop available to examine your qvw and to post a new one, but I think my example below should work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TableA:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;Category, Brand, Quantity, Month, Year, YearMonth&lt;BR /&gt;Electronics, LG, 20, 8, 2018, 2018-08&lt;BR /&gt;Electronics, LG, 30, 12, 2018, 2018-12&lt;BR /&gt;Electronics, LG, 40, 4, 2019, 2019-04&lt;BR /&gt;Electronics, LG, 50, 12, 2019, 2019-12&lt;/P&gt;&lt;P&gt;DRINKS, COKE, 20, 12, 2017, 2017-12&lt;/P&gt;&lt;P&gt;DRINKS, COKE, 20, 12, 2018, 2018-12&lt;BR /&gt;FRUITS, APPLE, 25, 12, 2018, 2018-12];&lt;/P&gt;&lt;P&gt;Inner join (TableA)&lt;/P&gt;&lt;P&gt;Load Category,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brand,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Month,&amp;nbsp;&lt;/P&gt;&lt;P&gt;max(Year) as Year&lt;/P&gt;&lt;P&gt;Resident TableA&lt;/P&gt;&lt;P&gt;Where Month=12&lt;/P&gt;&lt;P&gt;Group by Category, Brand, Month;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2019 07:03:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Take-the-latest-data-for-a-particular-month/m-p/1659932#M448670</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2019-12-21T07:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Take the latest data for a particular month</title>
      <link>https://community.qlik.com/t5/QlikView/Take-the-latest-data-for-a-particular-month/m-p/1659934#M448671</link>
      <description>&lt;P&gt;Great. It works&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2019 08:58:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Take-the-latest-data-for-a-particular-month/m-p/1659934#M448671</guid>
      <dc:creator>safik003</dc:creator>
      <dc:date>2019-12-21T08:58:40Z</dc:date>
    </item>
  </channel>
</rss>

