<?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: Set Analysis and IF Statement value differs in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520462#M1226563</link>
    <description>&lt;P&gt;I have very little information of the data behind and the possible selections, maybe you can try loading another table that groups by ID or Period, but if an ID can appear in different periods, and you want to count the distintic ID in the period selected by the user, I don't think you can precalculate that.&lt;/P&gt;</description>
    <pubDate>Sat, 07 Jun 2025 10:20:57 GMT</pubDate>
    <dc:creator>rubenmarin</dc:creator>
    <dc:date>2025-06-07T10:20:57Z</dc:date>
    <item>
      <title>Set Analysis and IF Statement value differs</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520451#M1226560</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've below sample data.&lt;/P&gt;&lt;P&gt;ID ID1 Period Type Type1&lt;/P&gt;&lt;P&gt;1 12 2023004 1 1&lt;/P&gt;&lt;P&gt;1 13 2023004 1 0&lt;/P&gt;&lt;P&gt;2 14 2023005 1 1&lt;/P&gt;&lt;P&gt;In the Front End I'm using the below set analysis expression and I got the output as '2'&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;=count(Distinct{&amp;lt;Type={'1'},Period-={'""'}&amp;gt;}ID)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm trying to migrate the above set analysis to backend script and for that I'm using below &lt;STRONG&gt;IF&amp;nbsp;&lt;/STRONG&gt;condition.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If(Type = '1' AND Period &amp;lt;&amp;gt; '""',Count(DISTINCT ID)) as NewValue&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;and &lt;STRONG&gt;sum(NewValue)&lt;/STRONG&gt;&amp;nbsp;I got the output as '3'.&lt;/P&gt;&lt;P&gt;In Set analysis I got output as '2' where as by using IF condition I got output as '3'. Can you help me understand where it is going wrong.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;V&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jun 2025 20:08:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520451#M1226560</guid>
      <dc:creator>vikasshana</dc:creator>
      <dc:date>2025-06-06T20:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis and IF Statement value differs</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520458#M1226561</link>
      <description>&lt;P&gt;Hi, the set analysis expression is calculated for all t he data, so the 'distinct ID' clause is only counting the ID 1 one time.&lt;/P&gt;&lt;P&gt;On the other hand I suppose NewValue is an added field to the table, or in a table with more than one row for ID=1, so the value of NewValue is 1 for each rows with ID=1, so the sum is 2.&lt;/P&gt;&lt;P&gt;You can check if this what is happening selecting the ID 1. The result of&amp;nbsp;"sum(NewValue)" is 2?&lt;/P&gt;&lt;P&gt;In this case you will need to group in some way that IDs are not repeated in different rows.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jun 2025 07:13:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520458#M1226561</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2025-06-07T07:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis and IF Statement value differs</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520461#M1226562</link>
      <description>&lt;P&gt;Yes if I select ID 1 I see&amp;nbsp;&lt;SPAN&gt;"sum(NewValue)" is 2. Any idea how to fix it?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jun 2025 08:54:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520461#M1226562</guid>
      <dc:creator>vikasshana</dc:creator>
      <dc:date>2025-06-07T08:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis and IF Statement value differs</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520462#M1226563</link>
      <description>&lt;P&gt;I have very little information of the data behind and the possible selections, maybe you can try loading another table that groups by ID or Period, but if an ID can appear in different periods, and you want to count the distintic ID in the period selected by the user, I don't think you can precalculate that.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jun 2025 10:20:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520462#M1226563</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2025-06-07T10:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis and IF Statement value differs</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520495#M1226564</link>
      <description>&lt;P&gt;If you want to do this is the script you will loss the dimention periode because will will aggergate the data. In the script you cant do that with a if statement but with a group by in the load statement. A if state wil only do a count on record level&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jun 2025 06:51:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520495#M1226564</guid>
      <dc:creator>Sierd_Boersma</dc:creator>
      <dc:date>2025-06-08T06:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis and IF Statement value differs</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520496#M1226565</link>
      <description>&lt;P&gt;Hi. The issue is fundamental…&lt;/P&gt;&lt;P&gt;you are doing: if….count&lt;/P&gt;&lt;P&gt;and you should be doing:&lt;/P&gt;&lt;P&gt;count(if……)&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jun 2025 07:04:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520496#M1226565</guid>
      <dc:creator>Lech_Miszkiewicz</dc:creator>
      <dc:date>2025-06-08T07:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis and IF Statement value differs</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520497#M1226566</link>
      <description>&lt;P&gt;I tried below two, but still the same&lt;/P&gt;&lt;P&gt;Count(DISTINCT If(TotalContractCount = '1' AND EndDate_Period_Scope &amp;lt;&amp;gt; '""',CONTRACT_ID)) as Denominator,&lt;BR /&gt;&lt;BR /&gt;OR&lt;BR /&gt;&lt;BR /&gt;Count(If(TotalContractCount = '1' AND EndDate_Period_Scope &amp;lt;&amp;gt; '""',CONTRACT_ID)) as Denominator,&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jun 2025 07:41:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520497#M1226566</guid>
      <dc:creator>vikasshana</dc:creator>
      <dc:date>2025-06-08T07:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis and IF Statement value differs</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520710#M1226570</link>
      <description>&lt;P&gt;Make sure that you don't count a key-field - this might be done by keeping the ID within the fact-table and replacing the key to a dimension with an autonumber-field.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 09:47:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-and-IF-Statement-value-differs/m-p/2520710#M1226570</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2025-06-10T09:47:34Z</dc:date>
    </item>
  </channel>
</rss>

