<?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 more than one 'if' in expression? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149197#M590091</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like this perhaps:&lt;/P&gt;&lt;P&gt;sum(Value_E)&lt;BR /&gt;* rangemax(1,num(GetFieldSelections(Field_A)))&lt;BR /&gt;* rangemax(1,num(GetFieldSelections(Field_B)))&lt;BR /&gt;* rangemax(1,num(GetFieldSelections(Field_C)))&lt;/P&gt;&lt;P&gt;If there are no field selections, I believe that part returns null. Rangemax() treats null as 0, so would then return 1, which means that portion of the calculation would do nothing, just as if the IF hadn't fired. So I don't think you need a complicated IF expression at all.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Jul 2009 02:18:18 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2009-07-14T02:18:18Z</dc:date>
    <item>
      <title>more than one 'if' in expression?</title>
      <link>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149193#M590087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was wondering if it was possible to have more than one if in the expression of a gauge chart (or any other chart, for that matter), something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;if(isnull(GetFieldSelections(Field_C) and isnull(GetFieldSelections(Field_B) and isnull(GetFieldSelections(Field_A), Sum(Value_E))&lt;BR /&gt;if(isnull(GetFieldSelections(Field_A)), Sum(Value_E), num(GetFieldSelections(Field_A)) * Sum(Value_E))&lt;BR /&gt;if(isnull(GetFieldSelections(Field_B)), Sum(Value_E), num(GetFieldSelections(Field_B)) * Sum(Value_E))&lt;BR /&gt;if(isnull(GetFieldSelections(Field_C)), Sum(Value_E), num(GetFieldSelections(Field_C)) * Sum(Value_E))&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;The gauge result will depend on what values are selected in fields A, B and C, and if no value is selected on these fields, then I just want it to display sum(Value_E).&lt;/P&gt;&lt;P&gt;The only alternative I see here is a very complicated set of chained if's...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Alexandra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2009 17:03:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149193#M590087</guid>
      <dc:creator />
      <dc:date>2009-07-13T17:03:44Z</dc:date>
    </item>
    <item>
      <title>more than one 'if' in expression?</title>
      <link>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149194#M590088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alexandra,&lt;/P&gt;&lt;P&gt;It doesn't have to be too complicated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;=if(isnull(GetFieldSelections(Field_C)) and isnull(GetFieldSelections(Field_B)) and isnull(GetFieldSelections(Field_A)), Sum(Value_E),&lt;BR /&gt; if(not isnull(GetFieldSelections(Field_A)), num(GetFieldSelections(Field_A)) * Sum(Value_E),&lt;BR /&gt; if(not isnull(GetFieldSelections(Field_B)), num(GetFieldSelections(Field_B)) * Sum(Value_E),&lt;BR /&gt; if(not isnull(GetFieldSelections(Field_C)), num(GetFieldSelections(Field_C)) * Sum(Value_E)&lt;BR /&gt;))))&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Note that this will not work if more than one item is selected in A, B, or C because GetFieldSelections returns a comma separated list.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2009 17:15:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149194#M590088</guid>
      <dc:creator>stephencredmond</dc:creator>
      <dc:date>2009-07-13T17:15:47Z</dc:date>
    </item>
    <item>
      <title>more than one 'if' in expression?</title>
      <link>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149195#M590089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stephen, thanks for your answer,&lt;/P&gt;&lt;P&gt;Indeed that expression doesn't seem very complicated, but the problem is the following: Values A, B and C start with no value selected. Then, on the course of the application use, the user selectes one value from Value_A and then another from Value_B (these are slider objects, btw, and so is Value_C).&lt;/P&gt;&lt;P&gt;So, you see, when one from Value_A is selected, the gauge calculates the expression, 'num(GetFieldSelections(Field_A)) * Sum(Value_E)', but then the user selects a value fom Value_B, with Value_A still being selected and QV is still going only for the first 'else' in the expression, not evaluating if Value_B has any selection.&lt;/P&gt;&lt;P&gt;What I want is for QV to take into account that Value_A is selected &lt;STRONG&gt;as well as&lt;/STRONG&gt; Value_B (and possibly even Value_C) and so I would like it to calculate 'num(GetFieldSelections(Field_A)) * Sum(Value_E)' and then again ' * num(GetFieldSelections(Field_B))'. That's why I want several if's, so QV can evaluate all the three values A, B and C...&lt;/P&gt;&lt;P&gt;Chained if's will lead QV to evaluate only the first that has any value.&lt;/P&gt;&lt;P&gt;kind of like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;int i = Sum(Value_E)&lt;BR /&gt;if(not isnull(GetFieldSelections(Field_A)))&lt;BR /&gt; i *= num(GetFieldSelections(Field_A))&lt;BR /&gt;if(not isnull(GetFieldSelections(Field_B)))&lt;BR /&gt; i *= num(GetFieldSelections(Field_B))&lt;BR /&gt;if(not isnull(GetFieldSelections(Field_C))&lt;BR /&gt;i *= num(GetFieldSelections(Field_C))&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2009 18:09:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149195#M590089</guid>
      <dc:creator />
      <dc:date>2009-07-13T18:09:36Z</dc:date>
    </item>
    <item>
      <title>more than one 'if' in expression?</title>
      <link>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149196#M590090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alexandra,&lt;/P&gt;&lt;P&gt;Not too difficult to code. Just looks long:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;=if(isnull(GetFieldSelections(Field_C)) and isnull(GetFieldSelections(Field_B)) and isnull(GetFieldSelections(Field_A)), Sum(Value_E),&lt;BR /&gt; if(not isnull(GetFieldSelections(Field_A)) and isnull(GetFieldSelections(Field_B)) and isnull(GetFieldSelections(Field_C)), num(GetFieldSelections(Field_A)) * Sum(Value_E),&lt;BR /&gt; if(not isnull(GetFieldSelections(Field_A)) and not isnull(GetFieldSelections(Field_B)) and isnull(GetFieldSelections(Field_C)), num(GetFieldSelections(Field_B)) * Sum(Value_E),&lt;BR /&gt; if(not isnull(GetFieldSelections(Field_C)), num(GetFieldSelections(Field_C)) * Sum(Value_E)&lt;BR /&gt;))))&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;You can include as many ifs as you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2009 18:42:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149196#M590090</guid>
      <dc:creator>stephencredmond</dc:creator>
      <dc:date>2009-07-13T18:42:33Z</dc:date>
    </item>
    <item>
      <title>more than one 'if' in expression?</title>
      <link>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149197#M590091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like this perhaps:&lt;/P&gt;&lt;P&gt;sum(Value_E)&lt;BR /&gt;* rangemax(1,num(GetFieldSelections(Field_A)))&lt;BR /&gt;* rangemax(1,num(GetFieldSelections(Field_B)))&lt;BR /&gt;* rangemax(1,num(GetFieldSelections(Field_C)))&lt;/P&gt;&lt;P&gt;If there are no field selections, I believe that part returns null. Rangemax() treats null as 0, so would then return 1, which means that portion of the calculation would do nothing, just as if the IF hadn't fired. So I don't think you need a complicated IF expression at all.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2009 02:18:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149197#M590091</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2009-07-14T02:18:18Z</dc:date>
    </item>
    <item>
      <title>more than one 'if' in expression?</title>
      <link>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149198#M590092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John, thank you so much, that's just it! Between null and 1, rangemax returns 1, it's perfect&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2009 15:54:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/more-than-one-if-in-expression/m-p/149198#M590092</guid>
      <dc:creator />
      <dc:date>2009-07-14T15:54:36Z</dc:date>
    </item>
  </channel>
</rss>

