<?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: Fill column value with previous not null value in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524024#M37592</link>
    <description>&lt;P&gt;May be try something like this&lt;/P&gt;&lt;PRE&gt;EMP:
LOAD * INLINE [
    EMPloyee, DATE1, Salary
    Ram, 2018-4-1, 1000
    Sham, 2018-4-1, 1000
    Ganesh, 2018-4-1, 1000
    Lakhan, 2018-4-1, 1000
    Ram, 2018-5-1, 1500
    Sham, 2018-5-1, 1500
    Ram, 2018-6-1, 2000
    Sham, 2018-6-1, 2000
    Lakhan, 2018-7-1, 2000
    Lakhan, 2018-9-1, 2500
    Ram, 2018-9-1, 3000
    Lakhan, 2018-9-1, 3000
];

NoConcatenate
EmployeeHistory:
LOAD EMPloyee,
	 Date(DATE1) as Date,
	 Salary,
	 EMPloyee&amp;amp;Date(DATE1) as Emp_Date_Key
Resident EMP;

DROP Table EMP;

MinMaxDate:
Load Min(Date) as MinDate,
	 Max(Date) as MaxDate
Resident EmployeeHistory;

LET vMinDate = Peek('MinDate',-1,'MinMaxDate')-1;
LET vMaxDate = Peek('MaxDate',-1,'MinMaxDate');

Temp:
LOAD Date(MonthStart($(vMinDate), IterNo()-1)) as Date
Autogenerate 1
While MonthStart($(vMinDate), IterNo()-1) &amp;lt;= $(vMaxDate);

Left Join (Temp)
LOAD Distinct EMPloyee
Resident EmployeeHistory;

Concatenate (EmployeeHistory)
LOAD Date,
	 EMPloyee
Resident Temp
Where not Exists(Emp_Date_Key, EMPloyee&amp;amp;Date(Date));

DROP Table Temp;

NoConcatenate
Employee:
LOAD Date,
	 EMPloyee,
	 If(EMPloyee = Previous(EMPloyee),
	 	If(IsNull(Salary), Peek('FinalSalary'), Salary), Salary) as FinalSalary
Resident EmployeeHistory
Order By EMPloyee, Date; /* so that above values can be propagated downwards */

DROP Tables MinMaxDate, EmployeeHistory;&lt;/PRE&gt;</description>
    <pubDate>Wed, 26 Dec 2018 12:09:49 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2018-12-26T12:09:49Z</dc:date>
    <item>
      <title>Fill column value with previous not null value</title>
      <link>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524005#M37587</link>
      <description>&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;I have a below table i want update salary of each employee basis on month wise also where&amp;nbsp; salary is null assign previous month or latest available of that month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Raw data is as below :&lt;/P&gt;&lt;P&gt;EMP:&lt;BR /&gt;Load * Inline&lt;BR /&gt;[EMPloyee, DATE1 , Salary&lt;BR /&gt;Ram, 2018-4-1,1000&lt;BR /&gt;Sham,2018-4-1,1000&lt;BR /&gt;Ganesh,2018-4-1,1000&lt;BR /&gt;Lakhan,2018-4-1,1000&lt;BR /&gt;Ram,2018-5-1,1500&lt;BR /&gt;Sham,2018-5-1,1500&lt;BR /&gt;Ram,2018-6-1,2000&lt;BR /&gt;Sham,2018-6-1,2000&lt;BR /&gt;Lakhan,2018-7-1,2000&lt;BR /&gt;Lakhan,2018-9-1,2500&lt;BR /&gt;Ram,2018-9-1,3000&lt;BR /&gt;Lakhan,2018-9-1,3000&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;BR /&gt;EmployeeHistory:&lt;BR /&gt;Load EMPloyee,Date(DATE1) as Date,Salary Resident EMP;&lt;BR /&gt;Drop Table EMP;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;MinMaxDate:&lt;BR /&gt;Load Min (Date) as MinDate , Max (Date) as MaxDate resident EmployeeHistory;&lt;/P&gt;&lt;P&gt;Let vMinDate = Peek('MinDate',-1,'MinMaxDate')-1;&lt;BR /&gt;Let vMaxDate = Peek('MaxDate',-1,'MinMaxDate');&lt;BR /&gt;&lt;BR /&gt;Join (EmployeeHistory)&lt;BR /&gt;Load Date(recno()+$(vMinDate)) as Date Autogenerate vMaxDate - vMinDate;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NoConcatenate&lt;BR /&gt;Employee:&lt;BR /&gt;Load Date, EMPloyee,&lt;BR /&gt;If(IsNull(Salary), Peek(Salary),Salary) as FinalSalary&lt;BR /&gt;Resident EmployeeHistory&lt;BR /&gt;order by Date; /* so that above values can be propagated downwards */&lt;/P&gt;&lt;P&gt;Drop Table MinMaxDate, EmployeeHistory;&lt;BR /&gt;Exit Script;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;O/p:&lt;/P&gt;&lt;P&gt;If I Select Ram:&lt;/P&gt;&lt;P&gt;Employee&amp;nbsp; &amp;nbsp;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Salary&lt;/P&gt;&lt;P&gt;Ram&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1-4-2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1000&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ram&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1-5-2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1500&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ram&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1-6-2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ram&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1-7-2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ram&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1-8-2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ram&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1-9-2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please help me get this&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 06:58:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524005#M37587</guid>
      <dc:creator>arvind_patil</dc:creator>
      <dc:date>2024-11-16T06:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Fill column value with previous not null value</title>
      <link>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524007#M37588</link>
      <description>&lt;P&gt;This post might be helpful here:&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/How-to-populate-a-sparsely-populated-field/ba-p/1470637" target="_self"&gt;How to populate sparsely populated field&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Dec 2018 11:33:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524007#M37588</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2018-12-26T11:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Fill column value with previous not null value</title>
      <link>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524010#M37589</link>
      <description>You have to perform multiple steps to achieve required result.&lt;BR /&gt;&lt;BR /&gt;Use below logic to get required output&lt;BR /&gt;&lt;BR /&gt;1: Load distinct date from base data table&lt;BR /&gt;2: load distinct employee from base table.&lt;BR /&gt;3: cross join with o/p of 1 and 2nd step.&lt;BR /&gt;4: load o/p of 3rd table then left join it with base table on the key of date &amp;amp; employeeName&lt;BR /&gt;5: sort o/p of table 4 by date, employeeName&lt;BR /&gt;6: use peek() and if() together to find the missing salary.&lt;BR /&gt;7: drop unnecessary table.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Prashant Sangle</description>
      <pubDate>Wed, 26 Dec 2018 11:36:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524010#M37589</guid>
      <dc:creator>PrashantSangle</dc:creator>
      <dc:date>2018-12-26T11:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Fill column value with previous not null value</title>
      <link>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524021#M37590</link>
      <description>&lt;P&gt;Dear Prashant,&lt;/P&gt;&lt;P&gt;Thanks for your reply. But&amp;nbsp; here I required exact logic. I allready know the steps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; regards,&lt;/P&gt;&lt;P&gt;Arvind Patil&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Dec 2018 12:01:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524021#M37590</guid>
      <dc:creator>arvind_patil</dc:creator>
      <dc:date>2018-12-26T12:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Fill column value with previous not null value</title>
      <link>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524022#M37591</link>
      <description>&lt;P&gt;Dear Tresco,&lt;/P&gt;&lt;P&gt;I have refer same example but I require output with&amp;nbsp; a&amp;nbsp;column employee .&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Arvind Patil&lt;/P&gt;</description>
      <pubDate>Wed, 26 Dec 2018 12:04:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524022#M37591</guid>
      <dc:creator>arvind_patil</dc:creator>
      <dc:date>2018-12-26T12:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: Fill column value with previous not null value</title>
      <link>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524024#M37592</link>
      <description>&lt;P&gt;May be try something like this&lt;/P&gt;&lt;PRE&gt;EMP:
LOAD * INLINE [
    EMPloyee, DATE1, Salary
    Ram, 2018-4-1, 1000
    Sham, 2018-4-1, 1000
    Ganesh, 2018-4-1, 1000
    Lakhan, 2018-4-1, 1000
    Ram, 2018-5-1, 1500
    Sham, 2018-5-1, 1500
    Ram, 2018-6-1, 2000
    Sham, 2018-6-1, 2000
    Lakhan, 2018-7-1, 2000
    Lakhan, 2018-9-1, 2500
    Ram, 2018-9-1, 3000
    Lakhan, 2018-9-1, 3000
];

NoConcatenate
EmployeeHistory:
LOAD EMPloyee,
	 Date(DATE1) as Date,
	 Salary,
	 EMPloyee&amp;amp;Date(DATE1) as Emp_Date_Key
Resident EMP;

DROP Table EMP;

MinMaxDate:
Load Min(Date) as MinDate,
	 Max(Date) as MaxDate
Resident EmployeeHistory;

LET vMinDate = Peek('MinDate',-1,'MinMaxDate')-1;
LET vMaxDate = Peek('MaxDate',-1,'MinMaxDate');

Temp:
LOAD Date(MonthStart($(vMinDate), IterNo()-1)) as Date
Autogenerate 1
While MonthStart($(vMinDate), IterNo()-1) &amp;lt;= $(vMaxDate);

Left Join (Temp)
LOAD Distinct EMPloyee
Resident EmployeeHistory;

Concatenate (EmployeeHistory)
LOAD Date,
	 EMPloyee
Resident Temp
Where not Exists(Emp_Date_Key, EMPloyee&amp;amp;Date(Date));

DROP Table Temp;

NoConcatenate
Employee:
LOAD Date,
	 EMPloyee,
	 If(EMPloyee = Previous(EMPloyee),
	 	If(IsNull(Salary), Peek('FinalSalary'), Salary), Salary) as FinalSalary
Resident EmployeeHistory
Order By EMPloyee, Date; /* so that above values can be propagated downwards */

DROP Tables MinMaxDate, EmployeeHistory;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Dec 2018 12:09:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524024#M37592</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-12-26T12:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Fill column value with previous not null value</title>
      <link>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524035#M37593</link>
      <description>&lt;P&gt;Hi Sunny,&lt;/P&gt;&lt;P&gt;It works.&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Arvind Patil&lt;/P&gt;</description>
      <pubDate>Wed, 26 Dec 2018 12:40:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Fill-column-value-with-previous-not-null-value/m-p/1524035#M37593</guid>
      <dc:creator>arvind_patil</dc:creator>
      <dc:date>2018-12-26T12:40:13Z</dc:date>
    </item>
  </channel>
</rss>

