<?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: Create flag field in script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Create-flag-field-in-script/m-p/276035#M102999</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or enclose it in double quotes or brackets.&amp;nbsp; The sum() probably didn't work because you weren't doing a group by.&amp;nbsp; It sounds like you don't need a group by, though, and can just get rid of the sum().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;if(Gross=0,'N','Y') as "Gross Flag"&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Jul 2011 22:28:47 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2011-07-12T22:28:47Z</dc:date>
    <item>
      <title>Create flag field in script</title>
      <link>https://community.qlik.com/t5/QlikView/Create-flag-field-in-script/m-p/276033#M102997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to create a new field called CommissionFlag to indentify customers who have commission over a time period vs those who don't.&amp;nbsp; &lt;/P&gt;&lt;P&gt;I've tried the below syntax but get an Invalid expression error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt;Gross,&lt;/P&gt;&lt;P&gt;if(sum(Gross)&amp;gt;0,'Y','N') as Gross Flag&lt;/P&gt;&lt;P&gt;From...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also tried this, but I get the "Execution of script failed. Reload old data?" box:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt;Gross,&lt;/P&gt;&lt;P&gt;if(Gross=0,'N','Y') as Gross Flag&lt;/P&gt;&lt;P&gt;From...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions on how to create the flag/field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 21:44:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-flag-field-in-script/m-p/276033#M102997</guid>
      <dc:creator />
      <dc:date>2011-07-12T21:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create flag field in script</title>
      <link>https://community.qlik.com/t5/QlikView/Create-flag-field-in-script/m-p/276034#M102998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looks like writing the field name "Gross Flag" is incorrect. Just do not separate the words: GrossFlag.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This script is working for me with loading from Excel:&lt;/P&gt;&lt;DIV&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;P&gt;LOAD ID, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldA,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(ID = 5, 'Y', 'N') as GrossFlag&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;[..\Fields.xlsx]&lt;/P&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt; &lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;P&gt;(ooxml, embedded labels);&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt; &lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&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;STRONG&gt;&lt;STRONG&gt;﻿&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;﻿&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;﻿regards,&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;﻿&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;﻿&lt;/STRONG&gt;&lt;/STRONG&gt;wojciechg&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;﻿&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 22:16:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-flag-field-in-script/m-p/276034#M102998</guid>
      <dc:creator />
      <dc:date>2011-07-12T22:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create flag field in script</title>
      <link>https://community.qlik.com/t5/QlikView/Create-flag-field-in-script/m-p/276035#M102999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or enclose it in double quotes or brackets.&amp;nbsp; The sum() probably didn't work because you weren't doing a group by.&amp;nbsp; It sounds like you don't need a group by, though, and can just get rid of the sum().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;if(Gross=0,'N','Y') as "Gross Flag"&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 22:28:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-flag-field-in-script/m-p/276035#M102999</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-07-12T22:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create flag field in script</title>
      <link>https://community.qlik.com/t5/QlikView/Create-flag-field-in-script/m-p/276036#M103000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The space in the &lt;STRONG&gt;Gross Flag&lt;/STRONG&gt; field name is acceptable if you simply enclose in square brackets, eg. &lt;STRONG&gt;[Gross Flag]&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first statement would have failed as you had a &lt;STRONG&gt;Sum &lt;/STRONG&gt;statement without a &lt;STRONG&gt;Group By&lt;/STRONG&gt; clause.&amp;nbsp; If you sum one column you need to sub all the others also.&amp;nbsp; This is usually not a good thing as removing detail means that QlikView can not do as much in depth analysis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second statement will work fine, but will return 'Y' even if the values in the &lt;STRONG&gt;Gross &lt;/STRONG&gt;field net out to zero (eg, 20, -5, -15).&amp;nbsp; I don't know if this will cause an issue?&amp;nbsp; If so you will either need to aggregate all your data or have two tables in your data model - one with the detail and the other with the flag in it - where the flag is on the aggregated values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 22:29:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-flag-field-in-script/m-p/276036#M103000</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2011-07-12T22:29:11Z</dc:date>
    </item>
  </channel>
</rss>

