<?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: Suppressing NULL values in a sum in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329685#M121366</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So in a chart you probably want something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Calibri; font-size: 12pt;"&gt;&lt;STRONG&gt;=sum( if( not Len(trim(purgechar(LeadSource, chr(160)))), SaleAmount)) &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or you work out a field value replacement like suggested by giampero and just check for &lt;EM&gt;not isnull(LeadSource). &lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 May 2012 15:01:46 GMT</pubDate>
    <dc:creator>swuehl</dc:creator>
    <dc:date>2012-05-30T15:01:46Z</dc:date>
    <item>
      <title>Suppressing NULL values in a sum</title>
      <link>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329681#M121362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I am processing a sales file which includes the "SaleAmount" and the "LeadSource". In many cases, the LeadSource field is either blank or NULL. When I load the data file into Excel to inspect it, some of these "missing" LeadSource files come up as "-" (i.e. a hyphen, ASCII char 45), or they come up as completely null - i.e if you test them in Excel with IsBlank, it returns FALSE (the cell in NOT blank), and using a cell viewer utility, there is no character whatsovever in the field (that is, the cell is what I would call "null"). I've read a bunch of topics here, and I've tried various script combinations of NullAsValue LeadSource, Set NullValue as "TestNull", Set NullDisplay as "TestNull", but when I reload, there is still a completely blank entry in the LeadSource table AND an entry "-" in the LeadSource table, both of which have a number of values associated with them that skew the results we're interested in. So, I have two questions: 1) How do I get these null values in my data to show up as "TestNull" in my table (I want to see this just to ensure I know what's going on), and more important, how, when I calculate the sum of "SaleAmount" do I get the formula to ignore the rows that have 'null' in LeadSource? If I were writing procedural code, it would be: IF LeadSource = null THEN TotalSale = (TotalSale+ 0) ELSE TotalSale = TotalSale + SaleAmount. But I'm stumped after a number of tries of doing this with sum(if.. in various configurations. Thanks in advance for your help. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2012 13:40:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329681#M121362</guid>
      <dc:creator />
      <dc:date>2012-05-30T13:40:55Z</dc:date>
    </item>
    <item>
      <title>Suppressing NULL values in a sum</title>
      <link>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329682#M121363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;have you tried in your script to force the field in this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF(len(Trim(LeadSource))&amp;gt;0,LeadSource,Null()) as LeadSource&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;Giampiero&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2012 14:11:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329682#M121363</guid>
      <dc:creator />
      <dc:date>2012-05-30T14:11:09Z</dc:date>
    </item>
    <item>
      <title>Suppressing NULL values in a sum</title>
      <link>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329683#M121364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if I fully got your setting, you want to do all the checks / calculations in the script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could check for blank or NULL field values (see also &lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://community.qlik.com/message/182388#182388"&gt;http://community.qlik.com/message/182388&lt;/A&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;using in your load something like&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Calibri; font-size: 12pt;"&gt;&lt;STRONG&gt;if(Len(trim(purgechar(Field, chr(160))))=0,'Test',Field) as Field,&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or maybe try isnum() function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if(not isnum(Field),'Test',Field) as Field,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To calculate the sum, you could use rangesum() which will treat all non-numeric values as zero:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;rangesum(peek(TotalSale), SaleAmount) as TotalSale,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2012 14:18:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329683#M121364</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-05-30T14:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: Suppressing NULL values in a sum</title>
      <link>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329684#M121365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks for your help; let me try to be more clear:&lt;/P&gt;&lt;P&gt;In the script, I'm trying to change the value of the LeadSource field so that the null values show up as something I can read (e.g. "TestNull"). As I said, this is just so that I know what's going on with the data, (and maybe to show sales people why it's helpful to fill in all the fields..)&lt;/P&gt;&lt;P&gt;But to calculate the total sales, I am trying to use an expression within the chart. A simple sum(SaleAmount) doesn't work, as there are thousands of records that have a SaleAmount but which also have a null value for LeadSource. I don't want to make this calculation in the script. &lt;/P&gt;&lt;P&gt;Hope that is more clear. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2012 14:53:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329684#M121365</guid>
      <dc:creator />
      <dc:date>2012-05-30T14:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Suppressing NULL values in a sum</title>
      <link>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329685#M121366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So in a chart you probably want something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Calibri; font-size: 12pt;"&gt;&lt;STRONG&gt;=sum( if( not Len(trim(purgechar(LeadSource, chr(160)))), SaleAmount)) &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or you work out a field value replacement like suggested by giampero and just check for &lt;EM&gt;not isnull(LeadSource). &lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2012 15:01:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329685#M121366</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-05-30T15:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Suppressing NULL values in a sum</title>
      <link>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329686#M121367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi, I tried copying and pasting your formula directly into my script, but it highlights the comma after the "&amp;gt;0", and gives me "error in expression" when I try to load the script. Any thoughts?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2012 15:57:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329686#M121367</guid>
      <dc:creator />
      <dc:date>2012-05-30T15:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Suppressing NULL values in a sum</title>
      <link>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329687#M121368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hm, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't get an error highlighting with one of my script lines or giampero's line. My last post's line is for use in a chart expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No idea why you get an error in your script, could you post (the relevant part of) your script here? Or a sample QV file?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2012 16:33:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Suppressing-NULL-values-in-a-sum/m-p/329687#M121368</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-05-30T16:33:35Z</dc:date>
    </item>
  </channel>
</rss>

