<?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 Removing zero values in the backend in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Removing-zero-values-in-the-backend/m-p/1791948#M1210768</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have been working on this scenario wherein the task is to flow previous month Sales value if the Sales value for the current month is zero which seems simple but complications arise when maybe lets say some Sales values are shown as "-" or when lets say for any particular month for example we have a Sales value which shows 0 for April and in the next row also has a particular value for April.&lt;/P&gt;&lt;P&gt;It will be more clear when I will take you step by step and finally we will come to the point where I am stuck. Note: I am loading a qvd file in which only two fields are relevant for the transformation but I need all the fields later on for my Visualization.&lt;/P&gt;&lt;P&gt;Step1: I load the QVD and derive the field MonthYear which is critical here. The code is as follows:&lt;/P&gt;&lt;P&gt;Table1:&lt;BR /&gt;LOAD*,&lt;BR /&gt;Date(Date1,'DD/MM/YYYY') as Date,&lt;BR /&gt;MonthName(Date1) as MonthYear&lt;BR /&gt;FROM&lt;BR /&gt;Hello.qvd&lt;BR /&gt;(qvd) WHERE Product_Group = 'xyz' and Year(Date1) = '2020' ;&lt;/P&gt;&lt;P&gt;If at this point I draw a table box with fields MonthYear and Sales It will look&amp;nbsp; like:&lt;/P&gt;&lt;P&gt;MonthYear Sales&lt;BR /&gt;Jan 2020 2000&lt;BR /&gt;Feb 2020 1500&lt;BR /&gt;Mar 2020 0&lt;BR /&gt;Mar 2020 3200&lt;BR /&gt;Apr 2020 1700&lt;BR /&gt;Apr 2020 -&lt;BR /&gt;May 2020 5500&lt;BR /&gt;Jun 2020 -&lt;BR /&gt;Jul 2020 600&lt;BR /&gt;Aug 2020 2900&lt;BR /&gt;Sep 2020 1200&lt;BR /&gt;Oct 2020 4700&lt;BR /&gt;Nov 2020 550&lt;BR /&gt;Dec 2020 7500&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step2: For all the Sales values where the we have the value =&amp;nbsp; "-", I remove it and replace with 0. The code now looks like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table2:&lt;BR /&gt;Load*,&lt;BR /&gt;If(IsNull([Sales]) or [Sales]='',0,[Sales]) as Sales1&lt;BR /&gt;Resident Table1 order by Date;&lt;BR /&gt;Drop Table Table1;&lt;/P&gt;&lt;P&gt;MonthYear Sales1&lt;BR /&gt;Jan 2020 2000&lt;BR /&gt;Feb 2020 1500&lt;BR /&gt;Mar 2020 0&lt;BR /&gt;Mar 2020 3200&lt;BR /&gt;Apr 2020 0&lt;BR /&gt;Apr 2020 1700&lt;BR /&gt;May 2020 5500&lt;BR /&gt;Jun 2020 0&lt;BR /&gt;Jul 2020 600&lt;BR /&gt;Aug 2020 2900&lt;BR /&gt;Sep 2020 1200&lt;BR /&gt;Oct 2020 4700&lt;BR /&gt;Nov 2020 550&lt;BR /&gt;Dec 2020 7500&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step3:&amp;nbsp; Notice that June 2020 Sales1 value is still zero. Now according to my requirement if zero then it should be replaced by May 2020 i.e. 5500. So I write the following script:&lt;/P&gt;&lt;P&gt;Table3:&lt;BR /&gt;LOAD*,&lt;BR /&gt;if(Sales1=0,PREVIOUS (Sales1),Sales1) as Sales2&lt;BR /&gt;resident Table2;&lt;BR /&gt;Drop Table Table2;&lt;/P&gt;&lt;P&gt;The table box now looks like:&lt;/P&gt;&lt;P&gt;MonthYear Sales2&lt;BR /&gt;Jan 2020 2000&lt;BR /&gt;Feb 2020 1500&lt;BR /&gt;Mar 2020 0&lt;BR /&gt;Mar 2020 3200&lt;BR /&gt;Apr 2020 0&lt;BR /&gt;Apr 2020 1700&lt;BR /&gt;May 2020 5500&lt;BR /&gt;Jun 2020 0&lt;BR /&gt;Jun 2020 5500&lt;BR /&gt;Jul 2020 600&lt;BR /&gt;Aug 2020 2900&lt;BR /&gt;Sep 2020 1200&lt;BR /&gt;Oct 2020 4700&lt;BR /&gt;Nov 2020 550&lt;BR /&gt;Dec 2020 7500&lt;/P&gt;&lt;P&gt;Now as you can see March, April and June still have records for Sales=0 and below them are the desired Sales Values.&lt;/P&gt;&lt;P&gt;Now I want to delete the those records still showing 0 Sales. How to achieve this?&lt;/P&gt;&lt;P&gt;Also is there a better way for doing all that I've done above...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Mar 2021 17:21:46 GMT</pubDate>
    <dc:creator>ritvik4BI</dc:creator>
    <dc:date>2021-03-16T17:21:46Z</dc:date>
    <item>
      <title>Removing zero values in the backend</title>
      <link>https://community.qlik.com/t5/QlikView/Removing-zero-values-in-the-backend/m-p/1791948#M1210768</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have been working on this scenario wherein the task is to flow previous month Sales value if the Sales value for the current month is zero which seems simple but complications arise when maybe lets say some Sales values are shown as "-" or when lets say for any particular month for example we have a Sales value which shows 0 for April and in the next row also has a particular value for April.&lt;/P&gt;&lt;P&gt;It will be more clear when I will take you step by step and finally we will come to the point where I am stuck. Note: I am loading a qvd file in which only two fields are relevant for the transformation but I need all the fields later on for my Visualization.&lt;/P&gt;&lt;P&gt;Step1: I load the QVD and derive the field MonthYear which is critical here. The code is as follows:&lt;/P&gt;&lt;P&gt;Table1:&lt;BR /&gt;LOAD*,&lt;BR /&gt;Date(Date1,'DD/MM/YYYY') as Date,&lt;BR /&gt;MonthName(Date1) as MonthYear&lt;BR /&gt;FROM&lt;BR /&gt;Hello.qvd&lt;BR /&gt;(qvd) WHERE Product_Group = 'xyz' and Year(Date1) = '2020' ;&lt;/P&gt;&lt;P&gt;If at this point I draw a table box with fields MonthYear and Sales It will look&amp;nbsp; like:&lt;/P&gt;&lt;P&gt;MonthYear Sales&lt;BR /&gt;Jan 2020 2000&lt;BR /&gt;Feb 2020 1500&lt;BR /&gt;Mar 2020 0&lt;BR /&gt;Mar 2020 3200&lt;BR /&gt;Apr 2020 1700&lt;BR /&gt;Apr 2020 -&lt;BR /&gt;May 2020 5500&lt;BR /&gt;Jun 2020 -&lt;BR /&gt;Jul 2020 600&lt;BR /&gt;Aug 2020 2900&lt;BR /&gt;Sep 2020 1200&lt;BR /&gt;Oct 2020 4700&lt;BR /&gt;Nov 2020 550&lt;BR /&gt;Dec 2020 7500&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step2: For all the Sales values where the we have the value =&amp;nbsp; "-", I remove it and replace with 0. The code now looks like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table2:&lt;BR /&gt;Load*,&lt;BR /&gt;If(IsNull([Sales]) or [Sales]='',0,[Sales]) as Sales1&lt;BR /&gt;Resident Table1 order by Date;&lt;BR /&gt;Drop Table Table1;&lt;/P&gt;&lt;P&gt;MonthYear Sales1&lt;BR /&gt;Jan 2020 2000&lt;BR /&gt;Feb 2020 1500&lt;BR /&gt;Mar 2020 0&lt;BR /&gt;Mar 2020 3200&lt;BR /&gt;Apr 2020 0&lt;BR /&gt;Apr 2020 1700&lt;BR /&gt;May 2020 5500&lt;BR /&gt;Jun 2020 0&lt;BR /&gt;Jul 2020 600&lt;BR /&gt;Aug 2020 2900&lt;BR /&gt;Sep 2020 1200&lt;BR /&gt;Oct 2020 4700&lt;BR /&gt;Nov 2020 550&lt;BR /&gt;Dec 2020 7500&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step3:&amp;nbsp; Notice that June 2020 Sales1 value is still zero. Now according to my requirement if zero then it should be replaced by May 2020 i.e. 5500. So I write the following script:&lt;/P&gt;&lt;P&gt;Table3:&lt;BR /&gt;LOAD*,&lt;BR /&gt;if(Sales1=0,PREVIOUS (Sales1),Sales1) as Sales2&lt;BR /&gt;resident Table2;&lt;BR /&gt;Drop Table Table2;&lt;/P&gt;&lt;P&gt;The table box now looks like:&lt;/P&gt;&lt;P&gt;MonthYear Sales2&lt;BR /&gt;Jan 2020 2000&lt;BR /&gt;Feb 2020 1500&lt;BR /&gt;Mar 2020 0&lt;BR /&gt;Mar 2020 3200&lt;BR /&gt;Apr 2020 0&lt;BR /&gt;Apr 2020 1700&lt;BR /&gt;May 2020 5500&lt;BR /&gt;Jun 2020 0&lt;BR /&gt;Jun 2020 5500&lt;BR /&gt;Jul 2020 600&lt;BR /&gt;Aug 2020 2900&lt;BR /&gt;Sep 2020 1200&lt;BR /&gt;Oct 2020 4700&lt;BR /&gt;Nov 2020 550&lt;BR /&gt;Dec 2020 7500&lt;/P&gt;&lt;P&gt;Now as you can see March, April and June still have records for Sales=0 and below them are the desired Sales Values.&lt;/P&gt;&lt;P&gt;Now I want to delete the those records still showing 0 Sales. How to achieve this?&lt;/P&gt;&lt;P&gt;Also is there a better way for doing all that I've done above...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 17:21:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Removing-zero-values-in-the-backend/m-p/1791948#M1210768</guid>
      <dc:creator>ritvik4BI</dc:creator>
      <dc:date>2021-03-16T17:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Removing zero values in the backend</title>
      <link>https://community.qlik.com/t5/QlikView/Removing-zero-values-in-the-backend/m-p/1792046#M1210778</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/131563"&gt;@ritvik4BI&lt;/a&gt;&amp;nbsp;, your script was almost ready, please check this script :&lt;/P&gt;&lt;P&gt;//the key is the function &lt;FONT color="#008000"&gt;&lt;STRONG&gt;peek&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table2:&lt;BR /&gt;Load&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;MonthYear,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Sales,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if(isnull(Sales) or Sales = 0 or Sales='', &lt;FONT color="#008000"&gt;&lt;STRONG&gt;peek&lt;/STRONG&gt;&lt;/FONT&gt;(Sales2), Sales) as Sales2&amp;nbsp;&lt;BR /&gt;Resident &lt;SPAN&gt;Table1&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;drop table &lt;SPAN&gt;Table1&lt;/SPAN&gt;;&amp;nbsp; //Optional&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 02:32:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Removing-zero-values-in-the-backend/m-p/1792046#M1210778</guid>
      <dc:creator>QFabian</dc:creator>
      <dc:date>2021-03-17T02:32:18Z</dc:date>
    </item>
  </channel>
</rss>

