<?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 If null(), get last value that had value in Visualization and Usability</title>
    <link>https://community.qlik.com/t5/Visualization-and-Usability/If-null-get-last-value-that-had-value/m-p/2062197#M228551</link>
    <description>&lt;P&gt;I have this data where some months I will have value for my item and other times I won't.&lt;BR /&gt;&amp;nbsp;I need that if it has no value that month, take the value of the last month that I had value:&lt;BR /&gt;&lt;BR /&gt;LOAD&lt;BR /&gt;"Cód. Estabelecimento" as Estab,&lt;BR /&gt;"Cód. Produto" as Item,&lt;BR /&gt;SubField(replace("val-unit-ggf-m",'.',','),';',1) as GGF,&lt;BR /&gt;"Período Preço Item" as Date&lt;BR /&gt;FROM &lt;BR /&gt;&lt;BR /&gt;How can I do this?&lt;/P&gt;</description>
    <pubDate>Wed, 19 Apr 2023 18:27:46 GMT</pubDate>
    <dc:creator>RafaelTorquato</dc:creator>
    <dc:date>2023-04-19T18:27:46Z</dc:date>
    <item>
      <title>If null(), get last value that had value</title>
      <link>https://community.qlik.com/t5/Visualization-and-Usability/If-null-get-last-value-that-had-value/m-p/2062197#M228551</link>
      <description>&lt;P&gt;I have this data where some months I will have value for my item and other times I won't.&lt;BR /&gt;&amp;nbsp;I need that if it has no value that month, take the value of the last month that I had value:&lt;BR /&gt;&lt;BR /&gt;LOAD&lt;BR /&gt;"Cód. Estabelecimento" as Estab,&lt;BR /&gt;"Cód. Produto" as Item,&lt;BR /&gt;SubField(replace("val-unit-ggf-m",'.',','),';',1) as GGF,&lt;BR /&gt;"Período Preço Item" as Date&lt;BR /&gt;FROM &lt;BR /&gt;&lt;BR /&gt;How can I do this?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 18:27:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Visualization-and-Usability/If-null-get-last-value-that-had-value/m-p/2062197#M228551</guid>
      <dc:creator>RafaelTorquato</dc:creator>
      <dc:date>2023-04-19T18:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: If null(), get last value that had value</title>
      <link>https://community.qlik.com/t5/Visualization-and-Usability/If-null-get-last-value-that-had-value/m-p/2062201#M228552</link>
      <description>&lt;LI-CODE lang="markup"&gt;noconcatenate
load *, if(isNull(Date), previous(Date),Date) as nDate resident sourceTable order by Item, Date;
drop table sourceTable;

drop field Date;
rename field nDate to Date;&lt;/LI-CODE&gt;
&lt;P&gt;Check something like this.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 18:38:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Visualization-and-Usability/If-null-get-last-value-that-had-value/m-p/2062201#M228552</guid>
      <dc:creator>mfchmielowski</dc:creator>
      <dc:date>2023-04-19T18:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: If null(), get last value that had value</title>
      <link>https://community.qlik.com/t5/Visualization-and-Usability/If-null-get-last-value-that-had-value/m-p/2062251#M228559</link>
      <description>&lt;P&gt;Unfortunately It's doesn't work&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 20:42:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Visualization-and-Usability/If-null-get-last-value-that-had-value/m-p/2062251#M228559</guid>
      <dc:creator>RafaelTorquato</dc:creator>
      <dc:date>2023-04-19T20:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: If null(), get last value that had value</title>
      <link>https://community.qlik.com/t5/Visualization-and-Usability/If-null-get-last-value-that-had-value/m-p/2062263#M228562</link>
      <description>&lt;P&gt;Hi Rafael,&lt;/P&gt;
&lt;P&gt;You will need to load the data with a specific sort order, by Establishment, Item and Date and then use the&amp;nbsp;&lt;STRONG&gt;PEEK&lt;/STRONG&gt; function to look back at the previous row.&lt;/P&gt;
&lt;P&gt;In order to use the ORDER BY&amp;nbsp; you may need to do a RESIDENT load, something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;NOCONCATENATE LOAD
  Estab,
  Item,
  Date,
  if(Estab = peek(Estab, -1) and Item = peek(Item, -1) and IsNull(GGF),
     peek(GGF, -1), GGF) as GGF
RESIDENT tmpDataTable
ORDER BY Estab, Item, Date;

DROP TABLE tmpDataTable;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will only work if there is only one row per date for each Estab and Item. I'm guessing that might not be the case with the SubField going on, so you might need to also do a group by.&lt;/P&gt;
&lt;P&gt;Hopefully this will help get you started in the right direction though.&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.quickintelligence.co.uk/blog/" target="_blank" rel="noopener"&gt;https://www.quickintelligence.co.uk/blog/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 22:07:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Visualization-and-Usability/If-null-get-last-value-that-had-value/m-p/2062263#M228562</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2023-04-19T22:07:32Z</dc:date>
    </item>
  </channel>
</rss>

