<?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 Sum-If with Text-Field in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Sum-If-with-Text-Field/m-p/2477059#M100331</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I've found a strange behaviour in Qlik Sense and QlikView and have created a simplified example.&lt;/P&gt;
&lt;P&gt;I'm using the following load script:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;LOAD 
  Text(Trim(VKORG))								 	as VKORG,
  Dual(Text(Trim(VKORG)), Num(Num#(VKORG))) 		as VKORG_DUAL,
  Year,
  Month
Inline [VKORG, Year, Month
1000,2024,1
1000,2024,2
1000,2024,3

2000,2024,1
2000,2024,2
2000,2024,3](delimiter is ',');&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I've created 2 simple tables, each containing a Sum(If...) expression like this:&lt;/P&gt;
&lt;PRE&gt;SUM(IF([VKORG] = '1000',&lt;BR /&gt;1,&lt;BR /&gt;0&lt;BR /&gt;)&lt;BR /&gt;)&lt;/PRE&gt;
&lt;P&gt;I did this for my Text- and my Dual-field. The result is as follows:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="msroha_0-1724161008532.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/170800i1F3F4EE58B03E874/image-size/medium?v=v2&amp;amp;px=400" role="button" title="msroha_0-1724161008532.png" alt="msroha_0-1724161008532.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The Sum-IF with the Text field (left side) only works correctly if I use a function like Trim() or WildMatch (or if I use "like" instead of "=")&lt;/P&gt;
&lt;P&gt;The Sum-IF with the Dual field (right side) works as I would expect.&lt;/P&gt;
&lt;P&gt;The behaviour is the same for Qlik Sense &amp;amp; QlikView (newest versions).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone know why this is happening? And is there a way to make it work without changing the expression or switching to dual?&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Tue, 20 Aug 2024 13:50:14 GMT</pubDate>
    <dc:creator>ms-roha</dc:creator>
    <dc:date>2024-08-20T13:50:14Z</dc:date>
    <item>
      <title>Sum-If with Text-Field</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-If-with-Text-Field/m-p/2477059#M100331</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I've found a strange behaviour in Qlik Sense and QlikView and have created a simplified example.&lt;/P&gt;
&lt;P&gt;I'm using the following load script:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;LOAD 
  Text(Trim(VKORG))								 	as VKORG,
  Dual(Text(Trim(VKORG)), Num(Num#(VKORG))) 		as VKORG_DUAL,
  Year,
  Month
Inline [VKORG, Year, Month
1000,2024,1
1000,2024,2
1000,2024,3

2000,2024,1
2000,2024,2
2000,2024,3](delimiter is ',');&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I've created 2 simple tables, each containing a Sum(If...) expression like this:&lt;/P&gt;
&lt;PRE&gt;SUM(IF([VKORG] = '1000',&lt;BR /&gt;1,&lt;BR /&gt;0&lt;BR /&gt;)&lt;BR /&gt;)&lt;/PRE&gt;
&lt;P&gt;I did this for my Text- and my Dual-field. The result is as follows:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="msroha_0-1724161008532.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/170800i1F3F4EE58B03E874/image-size/medium?v=v2&amp;amp;px=400" role="button" title="msroha_0-1724161008532.png" alt="msroha_0-1724161008532.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The Sum-IF with the Text field (left side) only works correctly if I use a function like Trim() or WildMatch (or if I use "like" instead of "=")&lt;/P&gt;
&lt;P&gt;The Sum-IF with the Dual field (right side) works as I would expect.&lt;/P&gt;
&lt;P&gt;The behaviour is the same for Qlik Sense &amp;amp; QlikView (newest versions).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone know why this is happening? And is there a way to make it work without changing the expression or switching to dual?&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 13:50:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-If-with-Text-Field/m-p/2477059#M100331</guid>
      <dc:creator>ms-roha</dc:creator>
      <dc:date>2024-08-20T13:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Sum-If with Text-Field</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-If-with-Text-Field/m-p/2477129#M100339</link>
      <description>&lt;P&gt;The operators &amp;lt; &amp;gt; = only work for operands that can be interpreted numerically.&lt;/P&gt;
&lt;P&gt;The result of the Text() function is a string for which numerical interpretation is not allowed.&lt;/P&gt;
&lt;P&gt;You have to use the comparison operators for strings: precedes, follows, like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUM(IF(VKORG like '1000',
 		1,
 		0
     )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 21:27:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-If-with-Text-Field/m-p/2477129#M100339</guid>
      <dc:creator>cwolf</dc:creator>
      <dc:date>2024-08-20T21:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sum-If with Text-Field</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-If-with-Text-Field/m-p/2477189#M100343</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;thank you I didn't know that.&lt;/P&gt;
&lt;P&gt;That makes me wonder why the "="-sign works when I use the Trim()-function, according to the documentation the Trim()-function also returns a string. I guess it allows for a numerical &lt;SPAN&gt;interpretation while the Text()-function removes it completely&lt;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;We've decided to replace the Text-Field with a dual and now everthing works as expected.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 08:04:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-If-with-Text-Field/m-p/2477189#M100343</guid>
      <dc:creator>ms-roha</dc:creator>
      <dc:date>2024-08-21T08:04:03Z</dc:date>
    </item>
  </channel>
</rss>

