<?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: If condition: compare strings without single quotes in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/If-condition-compare-strings-without-single-quotes/m-p/1701442#M63873</link>
    <description>&lt;P&gt;The&amp;nbsp;&lt;SPAN&gt;vCondition&amp;nbsp;variable contains a string value (A, B, C, ...) that is being modified by the extension 'Variable input'. Therefore, it contains no calculations.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 13 May 2020 09:06:50 GMT</pubDate>
    <dc:creator>mkliqvia</dc:creator>
    <dc:date>2020-05-13T09:06:50Z</dc:date>
    <item>
      <title>If condition: compare strings without single quotes</title>
      <link>https://community.qlik.com/t5/App-Development/If-condition-compare-strings-without-single-quotes/m-p/1701402#M63869</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Is there a way to write a comparison between a variable and a string in an IF-condition without single quotes '&amp;nbsp; ' ?&lt;/P&gt;&lt;P&gt;E.g. IF('$(vCondition)' = 'A', Field1, Field2)&lt;/P&gt;&lt;P&gt;Some &lt;STRONG&gt;background&lt;/STRONG&gt; of why I need this. I have been trying to implement the second solution written in &lt;A href="https://qlikviewcookbook.com/2014/12/how-not-to-choose-an-expression/" target="_self"&gt;this article&lt;/A&gt;. I have a graph that should show a certain measure from a list of calculation-intensive measures based on a condition. As we know, if you place multiple measures within an IF-condition, it will first calculate all the measures, and then provide the result, which makes the app slower and less repsonsive.&lt;/P&gt;&lt;P&gt;Therefore, from this article, I try to build this part:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Qlik forum.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/33494iEAB6F2CB33E1AD5C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Qlik forum.png" alt="Qlik forum.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see, for this we need our measures to be between single quotes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In my case&lt;/STRONG&gt;, I have something like this:&lt;BR /&gt;=if(vSelectMeasure=1,&lt;BR /&gt;'sum(IF('$(vCondition)' = 'A', Field1, Field2))',&lt;BR /&gt;'count(IF('$(vCondition)' = 'A', Field1, Field2))')&lt;/P&gt;&lt;P&gt;In this formula, we have single quotes to show which measure to use (outer-quotes), and within each measure, other single quotes to compare the condition with a string. These latter single quotes will make this fail as Qlik will think it represents the end of the first outer-quotes.&lt;/P&gt;&lt;P&gt;I have already tried multiple solutions not to have single quotes inside this formula, without success:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Tried to put double quotes here "$(vCondition)" = "A" or on the outside quotes&lt;/LI&gt;&lt;LI&gt;Tried to use chr(39) : IF( chr(39)&amp;amp;$(vCondition)&amp;amp;chr(39) = chr(39)&amp;amp;A&amp;amp;chr(39),&amp;nbsp;Field1, Field2)&lt;UL&gt;&lt;LI&gt;This provides a strange result as it returns True for any value of&amp;nbsp;vCondition, so it's not comparing.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Tried to put this condition in another variable (with and without an = sign before), but Qlik still reads this variable and stops at the first single quote.&lt;/LI&gt;&lt;LI&gt;Tried with pick(match()), but it behaves the same as IF.&lt;/LI&gt;&lt;LI&gt;Tried with the replace() function to replace a certain character with chr(39), but in there we still need to use single quotes around the special chars.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Do you have an idea of what else I could try to solve this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 18:39:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/If-condition-compare-strings-without-single-quotes/m-p/1701402#M63869</guid>
      <dc:creator>mkliqvia</dc:creator>
      <dc:date>2024-11-16T18:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: If condition: compare strings without single quotes</title>
      <link>https://community.qlik.com/t5/App-Development/If-condition-compare-strings-without-single-quotes/m-p/1701409#M63870</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Maybe this will work:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;=if(vSelectMeasure=1,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'sum(IF(' &amp;amp; chr(39) &amp;amp; '$(vCondition)' &amp;amp; chr(39) &amp;amp; ' = ' &amp;amp; chr(39) &amp;amp; 'A' &amp;amp; chr(39) &amp;amp; ', Field1, Field2))',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'count(IF(' &amp;amp; chr(39) &amp;amp; '$(vCondition)' &amp;amp; chr(39) &amp;amp; ' = ' &amp;amp; chr(39) &amp;amp; 'A' &amp;amp; chr(39) &amp;amp; ', Field1, Field2))')&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 08:02:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/If-condition-compare-strings-without-single-quotes/m-p/1701409#M63870</guid>
      <dc:creator>fosuzuki</dc:creator>
      <dc:date>2020-05-13T08:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: If condition: compare strings without single quotes</title>
      <link>https://community.qlik.com/t5/App-Development/If-condition-compare-strings-without-single-quotes/m-p/1701416#M63871</link>
      <description>&lt;P&gt;Hi, thanks for your suggestion, but that didn't work.&lt;/P&gt;&lt;P&gt;The single quotes '&amp;nbsp; ' are still being interpreted as the end of the outer-quotes in this formula.&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 08:22:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/If-condition-compare-strings-without-single-quotes/m-p/1701416#M63871</guid>
      <dc:creator>mkliqvia</dc:creator>
      <dc:date>2020-05-13T08:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: If condition: compare strings without single quotes</title>
      <link>https://community.qlik.com/t5/App-Development/If-condition-compare-strings-without-single-quotes/m-p/1701427#M63872</link>
      <description>&lt;P&gt;What is the content of vCondition variable?&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 08:38:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/If-condition-compare-strings-without-single-quotes/m-p/1701427#M63872</guid>
      <dc:creator>fosuzuki</dc:creator>
      <dc:date>2020-05-13T08:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: If condition: compare strings without single quotes</title>
      <link>https://community.qlik.com/t5/App-Development/If-condition-compare-strings-without-single-quotes/m-p/1701442#M63873</link>
      <description>&lt;P&gt;The&amp;nbsp;&lt;SPAN&gt;vCondition&amp;nbsp;variable contains a string value (A, B, C, ...) that is being modified by the extension 'Variable input'. Therefore, it contains no calculations.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 09:06:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/If-condition-compare-strings-without-single-quotes/m-p/1701442#M63873</guid>
      <dc:creator>mkliqvia</dc:creator>
      <dc:date>2020-05-13T09:06:50Z</dc:date>
    </item>
  </channel>
</rss>

