<?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: Autogenerate field with Month Year at the same time in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523021#M601137</link>
    <description>&lt;P&gt;Is this may be what you are looking for?&lt;/P&gt;&lt;PRE&gt;HRHISTORY:
LOAD *,
	 Date(MonthStart(Date),'MMM YYYY') as MonthYear;
LOAD * INLINE [
    Date, EMPLOYEE, JOB_CODE
    01/01/2017, 456, 20171
    06/01/2017, 456, 66666
    12/01/2018, 456, 20079
    02/01/2016, 333, 55555
    11/01/2018, 333, 20079
];

TempTable_HrHistory:
LOAD EMPLOYEE AS tEmp,
	 JOB_CODE as tJobCode
Resident HRHISTORY;

MinMaxDate:
LOAD Min(MonthYear) as MinDate,
	 Max(MonthYear) as MaxDate
Resident HRHISTORY;

LET vMinDate = Peek('MinDate',-1,'MinMaxDate') - 1;
LET vMaxDate = Peek('MaxDate',-1,'MinMaxDate') ;
DROP Table MinMaxDate;

Join (TempTable_HrHistory)
LOAD Date(MonthStart(RecNo() + $(vMinDate))) as tMonthYear
AutoGenerate vMaxDate - vMinDate;
DROP TABLE HRHISTORY;&lt;/PRE&gt;</description>
    <pubDate>Thu, 20 Dec 2018 13:43:33 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2018-12-20T13:43:33Z</dc:date>
    <item>
      <title>Autogenerate field with Month Year at the same time</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523014#M601136</link>
      <description>&lt;P&gt;I would like to generate a row for every employee with a month year and populate the the missing tJobCode. I believe I have the tJobCode populating correctly, just not getting tEMP for every record when the date is autogenerated.&lt;/P&gt;&lt;P&gt;What is the best approach to generate a field with every date?&amp;nbsp; The field I am trying to generate with&amp;nbsp;tMonthYear is the tEmp. Attached is the QVW as well.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;TempTable_HrHistory:
Load
EMPLOYEE AS tEmp,
MonthYear as tMonthYear,
JOB_CODE as tJobCode
Resident HRHISTORY;
//EXIT SCRIPT;


MinMaxDate:
Load Min(tMonthYear) as MinDate, Max(tMonthYear) as MaxDate resident TempTable_HrHistory;
Let vMinDate = Peek('MinDate',-1,'MinMaxDate') - 1;
Let vMaxDate = Peek('MaxDate',-1,'MinMaxDate') ;
Drop Table MinMaxDate;

Join (TempTable_HrHistory)
Load date(MonthStart(recno()+$(vMinDate))) as tMonthYear
//tEmp
 Autogenerate vMaxDate - vMinDate;

//exit SCRIPT;

FinalHR:
NoConcatenate Load tMonthYear,tEmp,
If( IsNull( tJobCode ), Peek( tJobCode ), tJobCode ) as tJobCode
Resident TempTable_HrHistory
Order By tMonthYear ;
Drop Table TempTable_HrHistory;
DROP TABLE HRHISTORY;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 21:42:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523014#M601136</guid>
      <dc:creator>jonathanrichey</dc:creator>
      <dc:date>2024-11-16T21:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate field with Month Year at the same time</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523021#M601137</link>
      <description>&lt;P&gt;Is this may be what you are looking for?&lt;/P&gt;&lt;PRE&gt;HRHISTORY:
LOAD *,
	 Date(MonthStart(Date),'MMM YYYY') as MonthYear;
LOAD * INLINE [
    Date, EMPLOYEE, JOB_CODE
    01/01/2017, 456, 20171
    06/01/2017, 456, 66666
    12/01/2018, 456, 20079
    02/01/2016, 333, 55555
    11/01/2018, 333, 20079
];

TempTable_HrHistory:
LOAD EMPLOYEE AS tEmp,
	 JOB_CODE as tJobCode
Resident HRHISTORY;

MinMaxDate:
LOAD Min(MonthYear) as MinDate,
	 Max(MonthYear) as MaxDate
Resident HRHISTORY;

LET vMinDate = Peek('MinDate',-1,'MinMaxDate') - 1;
LET vMaxDate = Peek('MaxDate',-1,'MinMaxDate') ;
DROP Table MinMaxDate;

Join (TempTable_HrHistory)
LOAD Date(MonthStart(RecNo() + $(vMinDate))) as tMonthYear
AutoGenerate vMaxDate - vMinDate;
DROP TABLE HRHISTORY;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 13:43:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523021#M601137</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-12-20T13:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate field with Month Year at the same time</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523042#M601138</link>
      <description>&lt;P&gt;No, Employee 333 has the earliest start date causing employee 456 to have a record on 02/01/2016.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 14:02:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523042#M601138</guid>
      <dc:creator>jonathanrichey</dc:creator>
      <dc:date>2018-12-20T14:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate field with Month Year at the same time</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523048#M601139</link>
      <description>&lt;P&gt;Check this may be&lt;/P&gt;&lt;PRE&gt;HRHISTORY:
LOAD *,
	 Date(MonthStart(Date),'MMM YYYY') as MonthYear;
LOAD * INLINE [
    Date, EMPLOYEE, JOB_CODE
    01/01/2017, 456, 20171
    06/01/2017, 456, 66666
    12/01/2018, 456, 20079
    02/01/2016, 333, 55555
    11/01/2018, 333, 20079
];

MinMaxDate:
LOAD Max(MonthYear) as MaxDate
Resident HRHISTORY;

LET vMaxDate = Peek('MaxDate',-1,'MinMaxDate') ;
DROP Table MinMaxDate;

FinalHR:
LOAD DISTINCT EMPLOYEE,
	 JOB_CODE,
	 Date(MonthStart(MonthYear, IterNo() - 1)) as MonthYear
Resident HRHISTORY
While MonthStart(MonthYear, IterNo() - 1) &amp;lt;= $(vMaxDate);
DROP TABLE HRHISTORY;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 14:12:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523048#M601139</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-12-20T14:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate field with Month Year at the same time</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523060#M601140</link>
      <description>&lt;P&gt;Close, but now the issue is duplicate job codes. I was trying to take the approach of not populating the jobcode when the date is created. This would allow the peak function to handle the months that are null and populate with the most recent jobcode.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;If( IsNull( tJobCode ), Peek( tJobCode ), tJobCode ) as tJobCode&lt;/PRE&gt;&lt;P&gt;Looking back at the orignal code, Is it possible to autogenerate the tEmp with the load statement below?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Join (TempTable_HrHistory)
Load date(MonthStart(recno()+$(vMinDate))) as tMonthYear
,tEmp
 Autogenerate vMaxDate - vMinDate;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 14:28:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523060#M601140</guid>
      <dc:creator>jonathanrichey</dc:creator>
      <dc:date>2018-12-20T14:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate field with Month Year at the same time</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523064#M601141</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/48169"&gt;@jonathanrichey&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Join (TempTable_HrHistory)
Load date(MonthStart(recno()+$(vMinDate))) as tMonthYear
,tEmp
 Autogenerate vMaxDate - vMinDate;&lt;/PRE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This is not possible because AutoGenerate cannot have a field from another table.&lt;/P&gt;&lt;P&gt;Taking a step back... what exactly do you need as an output? Would you be able to provide the required output in an Excel file based on the data you have provided in the sample?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 14:33:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523064#M601141</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-12-20T14:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate field with Month Year at the same time</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523072#M601142</link>
      <description>&lt;P&gt;Yes, attached is an excel sheet.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 15:01:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523072#M601142</guid>
      <dc:creator>jonathanrichey</dc:creator>
      <dc:date>2018-12-20T15:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate field with Month Year at the same time</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523080#M601143</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;PRE&gt;HRHISTORY:
LOAD * INLINE [
    Date, EMPLOYEE, JOB_CODE
    01/01/2017, 456, 20171
    06/01/2017, 456, 66666
    12/01/2018, 456, 20079
    02/01/2016, 333, 55555
    11/01/2018, 333, 20079
];

MinMaxDate:
LOAD Max(MonthStart(Date, 1)) as MaxDate
Resident HRHISTORY;

LET vMaxDate = Peek('MaxDate',-1,'MinMaxDate') ;
DROP Table MinMaxDate;

TempTable:
LOAD *,
	 Date(If(EMPLOYEE = Previous(EMPLOYEE), Previous(Date), '$(vMaxDate)')) as EndDate
Resident HRHISTORY
Order By EMPLOYEE, Date desc;
DROP Table HRHISTORY;

FinalHR:
LOAD DISTINCT EMPLOYEE,
	 JOB_CODE,
	 Date(MonthStart(Date, IterNo() - 1)) as MonthYear
Resident TempTable
While MonthStart(Date, IterNo() - 1) &amp;lt; EndDate;

DROP Table TempTable;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 15:11:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-field-with-Month-Year-at-the-same-time/m-p/1523080#M601143</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-12-20T15:11:42Z</dc:date>
    </item>
  </channel>
</rss>

