<?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: Filling in rows between start and end with conditions in Load Script in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Filling-in-rows-between-start-and-end-with-conditions-in-Load/m-p/1852818#M70424</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/40129"&gt;@Sazabi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;This code will fill out the missing dates and forward fill your missing status based on the objects being the same as the previous record.&lt;/P&gt;
&lt;P&gt;data:&lt;BR /&gt;load * Inline [&lt;BR /&gt;Object Date Status&lt;BR /&gt;A 1/1/2021 Active&lt;BR /&gt;A 1/3/2021 Inactive&lt;BR /&gt;B 1/2/2021 Inactive&lt;BR /&gt;B 1/6/2021 Active&lt;BR /&gt;](delimiter is '\t');&lt;/P&gt;
&lt;P&gt;//Load a distinct list of objects so the to the master date table will duplicate with the number of objects&lt;BR /&gt;Objects:&lt;BR /&gt;Load distinct&lt;BR /&gt;Object&lt;BR /&gt;Resident data;&lt;/P&gt;
&lt;P&gt;//Loop through from the minimum to maximum dates&lt;BR /&gt;join(Objects)&lt;BR /&gt;Load &lt;BR /&gt;date(monthstart(MinDate, IterNo()-1)) as Date&lt;BR /&gt;while monthstart(MinDate, IterNo()-1) &amp;lt;= MaxDate;&lt;BR /&gt;load&lt;BR /&gt;min(Date) as MinDate,&lt;BR /&gt;max(Date) as MaxDate&lt;BR /&gt;Resident data;&lt;/P&gt;
&lt;P&gt;// Join back to the data using the object and date as a key&lt;BR /&gt;Join(data)&lt;BR /&gt;Load&lt;BR /&gt;*&lt;BR /&gt;Resident Objects;&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;/P&gt;
&lt;P&gt;// Create a new status field based on Status and forward fill missing values where appropriate.&lt;BR /&gt;Output:&lt;BR /&gt;Load&lt;BR /&gt;*,&lt;BR /&gt;if( Object &amp;lt;&amp;gt; peek('Object'), &lt;BR /&gt;Status, &lt;BR /&gt;if(not isnull(Status), Status, peek('NextStatus')) ) as NextStatus&lt;BR /&gt;Resident data&lt;BR /&gt;order by Object, Date;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;drop table Objects, data;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="anthonyj_0-1635397404997.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/65442iE171C01FE5A1E919/image-size/medium?v=v2&amp;amp;px=400" role="button" title="anthonyj_0-1635397404997.png" alt="anthonyj_0-1635397404997.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Anthony&lt;/P&gt;</description>
    <pubDate>Thu, 28 Oct 2021 05:04:05 GMT</pubDate>
    <dc:creator>anthonyj</dc:creator>
    <dc:date>2021-10-28T05:04:05Z</dc:date>
    <item>
      <title>Filling in rows between start and end with conditions in Load Script</title>
      <link>https://community.qlik.com/t5/App-Development/Filling-in-rows-between-start-and-end-with-conditions-in-Load/m-p/1852071#M70378</link>
      <description>&lt;P&gt;Hi Qliksters,&lt;/P&gt;
&lt;P&gt;I have a table here and would like to generate dates per object + carry over the status between dates&lt;/P&gt;
&lt;P&gt;For example: Given this table&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;&lt;STRONG&gt;Object&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;&lt;STRONG&gt;Status&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;A&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1/1/2021&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Active&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;A&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1/3/2021&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Inactive&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;B&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1/2/2021&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Inactive&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;B&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1/6/2021&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Active&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make a table that looks like:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;&lt;STRONG&gt;Object&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;&lt;STRONG&gt;Status&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;A&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1/1/2021&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Active&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;A&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1/2/2021&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Active&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;A&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1/3/2021&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Active&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;A&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1/4/2021&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Inactive&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;A&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1/5/2021&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Inactive&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;A&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1/6/2021&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Inactive&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="40px"&gt;B&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="40px"&gt;
&lt;P&gt;1/1/2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="40px"&gt;NULL&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;B&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1/2/2021&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Inactive&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;B&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;1/3/2021&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Inactive&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;B&lt;/TD&gt;
&lt;TD height="25px"&gt;1/4/2021&lt;/TD&gt;
&lt;TD height="25px"&gt;Inactive&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;B&lt;/TD&gt;
&lt;TD height="25px"&gt;1/5/2021&lt;/TD&gt;
&lt;TD height="25px"&gt;Inactive&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;B&lt;/TD&gt;
&lt;TD height="25px"&gt;1/6/2021&lt;/TD&gt;
&lt;TD height="25px"&gt;Active&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the load script, is there a way to do so with some sort of looping mechanism?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;REF:&lt;BR /&gt;LOAD * INLINE [Object, Time, Status&lt;BR /&gt;A, 1/1/2021, Active&lt;BR /&gt;A, 1/3/2021, Inactive&lt;BR /&gt;B, 1/2/2021, Inactive&lt;BR /&gt;B, 1/6/2021, Active];&lt;/P&gt;
&lt;P&gt;Calendar:&lt;BR /&gt;LOAD * INLINE [Object, Time&lt;BR /&gt;A, 1/1/2021&lt;BR /&gt;A, 1/2/2021&lt;BR /&gt;A, 1/3/2021&lt;BR /&gt;A, 1/4/2021&lt;BR /&gt;A, 1/5/2021&lt;BR /&gt;A, 1/6/2021&lt;BR /&gt;B, 1/1/2021&lt;BR /&gt;B, 1/2/2021&lt;BR /&gt;B, 1/3/2021&lt;BR /&gt;B, 1/4/2021&lt;BR /&gt;B, 1/5/2021&lt;BR /&gt;B, 1/6/2021];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 18:53:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Filling-in-rows-between-start-and-end-with-conditions-in-Load/m-p/1852071#M70378</guid>
      <dc:creator>Sazabi</dc:creator>
      <dc:date>2021-10-26T18:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Filling in rows between start and end with conditions in Load Script</title>
      <link>https://community.qlik.com/t5/App-Development/Filling-in-rows-between-start-and-end-with-conditions-in-Load/m-p/1852818#M70424</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/40129"&gt;@Sazabi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;This code will fill out the missing dates and forward fill your missing status based on the objects being the same as the previous record.&lt;/P&gt;
&lt;P&gt;data:&lt;BR /&gt;load * Inline [&lt;BR /&gt;Object Date Status&lt;BR /&gt;A 1/1/2021 Active&lt;BR /&gt;A 1/3/2021 Inactive&lt;BR /&gt;B 1/2/2021 Inactive&lt;BR /&gt;B 1/6/2021 Active&lt;BR /&gt;](delimiter is '\t');&lt;/P&gt;
&lt;P&gt;//Load a distinct list of objects so the to the master date table will duplicate with the number of objects&lt;BR /&gt;Objects:&lt;BR /&gt;Load distinct&lt;BR /&gt;Object&lt;BR /&gt;Resident data;&lt;/P&gt;
&lt;P&gt;//Loop through from the minimum to maximum dates&lt;BR /&gt;join(Objects)&lt;BR /&gt;Load &lt;BR /&gt;date(monthstart(MinDate, IterNo()-1)) as Date&lt;BR /&gt;while monthstart(MinDate, IterNo()-1) &amp;lt;= MaxDate;&lt;BR /&gt;load&lt;BR /&gt;min(Date) as MinDate,&lt;BR /&gt;max(Date) as MaxDate&lt;BR /&gt;Resident data;&lt;/P&gt;
&lt;P&gt;// Join back to the data using the object and date as a key&lt;BR /&gt;Join(data)&lt;BR /&gt;Load&lt;BR /&gt;*&lt;BR /&gt;Resident Objects;&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;/P&gt;
&lt;P&gt;// Create a new status field based on Status and forward fill missing values where appropriate.&lt;BR /&gt;Output:&lt;BR /&gt;Load&lt;BR /&gt;*,&lt;BR /&gt;if( Object &amp;lt;&amp;gt; peek('Object'), &lt;BR /&gt;Status, &lt;BR /&gt;if(not isnull(Status), Status, peek('NextStatus')) ) as NextStatus&lt;BR /&gt;Resident data&lt;BR /&gt;order by Object, Date;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;drop table Objects, data;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="anthonyj_0-1635397404997.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/65442iE171C01FE5A1E919/image-size/medium?v=v2&amp;amp;px=400" role="button" title="anthonyj_0-1635397404997.png" alt="anthonyj_0-1635397404997.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Anthony&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 05:04:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Filling-in-rows-between-start-and-end-with-conditions-in-Load/m-p/1852818#M70424</guid>
      <dc:creator>anthonyj</dc:creator>
      <dc:date>2021-10-28T05:04:05Z</dc:date>
    </item>
  </channel>
</rss>

