<?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 Getting the count of a filter from an if statement in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Getting-the-count-of-a-filter-from-an-if-statement/m-p/2048004#M86180</link>
    <description>&lt;P&gt;I have a set of data that I am using to build a table. In that table, there are initial dates and completed dates. I have written an if statement to assign a new column to the table with a label that corresponds to the dates to state if it is on time or late&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ex:&amp;nbsp;If(not isnull([Revised Date]) and (Date([Revised Date]) &amp;lt; Today() and isnull([Completed Date])), 'Late'&lt;/P&gt;
&lt;P&gt;This works as intended. Now I need to display a count of the items that are late and a count of the items that are on time in a KPI. How do I count all of the conditions that fall within each if statement?&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2023 16:20:19 GMT</pubDate>
    <dc:creator>Evan0211</dc:creator>
    <dc:date>2023-03-10T16:20:19Z</dc:date>
    <item>
      <title>Getting the count of a filter from an if statement</title>
      <link>https://community.qlik.com/t5/App-Development/Getting-the-count-of-a-filter-from-an-if-statement/m-p/2048004#M86180</link>
      <description>&lt;P&gt;I have a set of data that I am using to build a table. In that table, there are initial dates and completed dates. I have written an if statement to assign a new column to the table with a label that corresponds to the dates to state if it is on time or late&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ex:&amp;nbsp;If(not isnull([Revised Date]) and (Date([Revised Date]) &amp;lt; Today() and isnull([Completed Date])), 'Late'&lt;/P&gt;
&lt;P&gt;This works as intended. Now I need to display a count of the items that are late and a count of the items that are on time in a KPI. How do I count all of the conditions that fall within each if statement?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 16:20:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Getting-the-count-of-a-filter-from-an-if-statement/m-p/2048004#M86180</guid>
      <dc:creator>Evan0211</dc:creator>
      <dc:date>2023-03-10T16:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the count of a filter from an if statement</title>
      <link>https://community.qlik.com/t5/App-Development/Getting-the-count-of-a-filter-from-an-if-statement/m-p/2048127#M86187</link>
      <description>&lt;P&gt;Hi, Using a Count If()&lt;/P&gt;
&lt;P&gt;=Count(DISTINCT If(not IsNull([Revised Date]) and (Date([Revised Date]) &amp;lt; Today() and IsNull([Completed Date])), Items))&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;Set Analysis&lt;/P&gt;
&lt;P&gt;=Count({&amp;lt;[Revised Date]={"&amp;lt;$(=Date(Today()))"},[Completed Date]={"=Len(Trim([Completed Date]))=0"},[Revised Date]={"=Len(Trim([Revised Date]))&amp;lt;&amp;gt;0"}&amp;gt;} DISTINCT Items)&lt;/P&gt;</description>
      <pubDate>Sat, 11 Mar 2023 07:52:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Getting-the-count-of-a-filter-from-an-if-statement/m-p/2048127#M86187</guid>
      <dc:creator>BrunPierre</dc:creator>
      <dc:date>2023-03-11T07:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the count of a filter from an if statement</title>
      <link>https://community.qlik.com/t5/App-Development/Getting-the-count-of-a-filter-from-an-if-statement/m-p/2048207#M86195</link>
      <description>&lt;P&gt;G'day&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/144230"&gt;@Evan0211&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/16737"&gt;@BrunPierre&lt;/a&gt;'s solution is correct but I would like to suggest an improvement. It is more efficient to if you create your extra column in the load script and the use that column in the Set Analysis.&lt;/P&gt;
&lt;P&gt;The most efficient is to create a flag like this ...&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;If( not isnull([Revised Date]) 
    and (Date([Revised Date]) &amp;lt; Today() 
    and isnull([Completed Date])), 1, 0 ) as isLate
&lt;/LI-CODE&gt;
&lt;P&gt;Then your Set Analysis looks like this ...&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;count( {$&amp;lt;isLate={1}&amp;gt;} distinct Item )&lt;/LI-CODE&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;Cheers, Barnaby.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Mar 2023 20:19:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Getting-the-count-of-a-filter-from-an-if-statement/m-p/2048207#M86195</guid>
      <dc:creator>barnabyd</dc:creator>
      <dc:date>2023-03-12T20:19:36Z</dc:date>
    </item>
  </channel>
</rss>

