<?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 should return null or zero, instead returns count of all in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1771499#M455529</link>
    <description>&lt;P&gt;I blindly trust on your model that may have some field associated with this otherwise data can be static rather data points? can you check that and confirm?&lt;/P&gt;</description>
    <pubDate>Sat, 02 Jan 2021 20:31:28 GMT</pubDate>
    <dc:creator>Anil_Babu_Samineni</dc:creator>
    <dc:date>2021-01-02T20:31:28Z</dc:date>
    <item>
      <title>set analysis should return null or zero, instead returns count of all</title>
      <link>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1726175#M455524</link>
      <description>&lt;P&gt;If we get a surge of Covid patients, and we need to activate our Overflow Emergency Department, we want to be able to know how many people are in that Department as soon as patients start being assigned to it. So I wrote a set analysis formula to count them:&lt;/P&gt;&lt;P&gt;=count({&amp;lt;Department={'EMERGENCY DEPARTMENT OVERFLOW'}&amp;gt;}Distinct PatientID)&lt;/P&gt;&lt;P&gt;Nobody is currently assigned to that Department. Yet instead of returning zero or null, it returns a count of ALL Distinct PatientIDs in the .qvw, even though none of them are associated with Department = 'EMERGENCY DEPARTMENT OVERFLOW'.&lt;/P&gt;&lt;P&gt;1) Why does it do this?&lt;BR /&gt;2) How can I work around this problem so that as soon as 1 patient is assigned that Department, the calculation returns an accurate value?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2020 15:39:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1726175#M455524</guid>
      <dc:creator>Margaret</dc:creator>
      <dc:date>2020-07-08T15:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: set analysis should return null or zero, instead returns count of all</title>
      <link>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1726230#M455525</link>
      <description>&lt;P&gt;can you share a sample data and the expected output ?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2020 18:24:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1726230#M455525</guid>
      <dc:creator>Taoufiq_Zarra</dc:creator>
      <dc:date>2020-07-08T18:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: set analysis should return null or zero, instead returns count of all</title>
      <link>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1726291#M455526</link>
      <description>&lt;P&gt;If this seems like anomolous behavior and going to the trouble of prepping a qvw with sharable (non-confidential) sample data is necessary, I will. But it seems like this may be Working as Designed, in which case I would like to understand it better and how others handle this kind of situation. So I'm interested in input on that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2020 22:22:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1726291#M455526</guid>
      <dc:creator>Margaret</dc:creator>
      <dc:date>2020-07-08T22:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: set analysis should return null or zero, instead returns count of all</title>
      <link>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1730238#M455527</link>
      <description>&lt;P&gt;About the best I can offer is the following Design Blog post that may provide some further information regarding Set Analysis:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/A-Primer-on-Set-Analysis/ba-p/1468344" target="_blank"&gt;https://community.qlik.com/t5/Qlik-Design-Blog/A-Primer-on-Set-Analysis/ba-p/1468344&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There are some further links to other posts at the bottom, just FYI.&lt;/P&gt;&lt;P&gt;If you want to search for other posts, use the following link:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog" target="_blank"&gt;https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hopefully that may get you what you need to explain things, the only other thing would be to review the Help documentation too:&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/ChartFunctions/SetAnalysis/set-analysis-expressions.htm" target="_blank"&gt;https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/ChartFunctions/SetAnalysis/set-analysis-expressions.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Brett&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 11:25:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1730238#M455527</guid>
      <dc:creator>Brett_Bleess</dc:creator>
      <dc:date>2020-07-23T11:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: set analysis should return null or zero, instead returns count of all</title>
      <link>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1771479#M455528</link>
      <description>&lt;P&gt;Can anyone speak to this kind of situation? It isn't an anomoly. It's happening again when I try to count how many patients are overdue for their second dose of Covid-19 vaccine (and other situations). Nobody is overdue yet. But this returns a count of EVERYONE:&lt;/P&gt;&lt;P&gt;=count({&amp;lt;OverdueForSecondDose={'Yes'}&amp;gt;}DISTINCT PatientID)&lt;/P&gt;&lt;P&gt;the workaround is to check if there is a value in that field at all, and not count it if there isn't:&lt;/P&gt;&lt;P&gt;if(LEN(OverdueForSecondDose) &amp;gt; 0&lt;BR /&gt;,count({&amp;lt;OverdueForSecondDose={'Yes'}&amp;gt;}DISTINCT PatientID)&lt;BR /&gt;,0&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;But I'd like to understand why it is doing that and hopefully learn how to calculate without having to check for the length of the value in OverdueForSecondDose.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jan 2021 16:18:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1771479#M455528</guid>
      <dc:creator>Margaret</dc:creator>
      <dc:date>2021-01-02T16:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: set analysis should return null or zero, instead returns count of all</title>
      <link>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1771499#M455529</link>
      <description>&lt;P&gt;I blindly trust on your model that may have some field associated with this otherwise data can be static rather data points? can you check that and confirm?&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jan 2021 20:31:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1771499#M455529</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2021-01-02T20:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: set analysis should return null or zero, instead returns count of all</title>
      <link>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1771655#M455530</link>
      <description>&lt;P&gt;The cause is that there are no values available for the field. If this happens the set analysis condition is just ignored and therefore the expression returned the results for the whole dataset. I agree that's from a user point of view not the expected behaviour. I assume that there are technically reasons because the set analysis logic based on the system- and state-tables and the normally returning TRUE or FALSE couldn't be assigned to NULL respectively to NOTHING. A technically solution for it might be to implement a further loop which checked each set analysis statement - but the performance impact would be probably quite huge. Therefore I believe it is like it is ...&lt;/P&gt;&lt;P&gt;An alternatively might be to ensure that there is always a field-value maybe with something like this:&lt;/P&gt;&lt;P&gt;concatenate(YourTable) load ' ' as YourField autogenerate 1;&lt;/P&gt;&lt;P&gt;Probably there are more elegant ways to implement such things and of course it has some side-effects especially if it's applied to a larger amount of fields.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Beside this you could try to bypass such cases by applying an indirect set analysis, maybe with something like this:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;count({&amp;lt;PatientID = {"=OverdueForSecondDose='Yes'"}&amp;gt;}DISTINCT PatientID)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;but it's not really better as your if-approach because it's mostly the same just the syntax is different.&lt;/P&gt;&lt;P&gt;In both above mentioned workarounds you need to know which fields have any values or not to apply any of these logics.&lt;/P&gt;&lt;P&gt;A more robust alternatively could be to adjust the datamodel to switch from a more or less crosstable-structure to a stream-data structure, means changing something from:&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp;First&amp;nbsp; &amp;nbsp;Second&amp;nbsp; &amp;nbsp;Third&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp;no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yes&lt;/P&gt;&lt;P&gt;to something like:&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp;Category&amp;nbsp; &amp;nbsp;Value&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;First&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;Second&amp;nbsp; &amp;nbsp; &amp;nbsp; no&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;Third&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the risk to run in such an issue should be massively reduced.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 14:32:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1771655#M455530</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2021-01-04T14:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: set analysis should return null or zero, instead returns count of all</title>
      <link>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1771664#M455531</link>
      <description>&lt;P&gt;Thank you, Marcus! That's super helpful.&lt;/P&gt;&lt;P&gt;I am also thinking about changing the SQL that creates the dataset to populate&amp;nbsp;&lt;SPAN&gt;OverdueForSecondDose with "No" when it is not "Yes". PatientIDs that don't exist in that dataset would still have null for that column but I think I need only one value for the simpler SetAnalysis to work properly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 14:59:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/set-analysis-should-return-null-or-zero-instead-returns-count-of/m-p/1771664#M455531</guid>
      <dc:creator>Margaret</dc:creator>
      <dc:date>2021-01-04T14:59:10Z</dc:date>
    </item>
  </channel>
</rss>

