<?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: Secondary filter to exclude values from measures in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Secondary-filter-to-exclude-values-from-measures/m-p/2438001#M97091</link>
    <description>&lt;P&gt;You gave me an insight using concat() and I managed to achieve what I wanted with a different approach. GetFieldSelections() will also concatenate the values and I can use it inside the set analysis&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For those who it might help, I used alternate states and getfieldselections:&lt;/P&gt;
&lt;P&gt;Filter 1 = product_brand (inherited state, no need for changes)&lt;/P&gt;
&lt;P&gt;Filter 2 (exclusion) = I created an alias field (product_brand_exc) and added a different state (e.g BrandExclusion) [maybe it's not necessary and you could use the same product_brand as it's using a different state]&lt;/P&gt;
&lt;P&gt;Then in the measure expression you could use GetFieldSelections() to retrieve the selected values in Filter 2:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Count(Distinct {&amp;lt;key_customer = E({BrandExclusion&amp;lt;product_brand = {$(=chr(39)&amp;amp;GetFieldSelections(product_brand_exc,''',''',10,'BrandExclusion')&amp;amp;chr(39))}&amp;gt;} key_customer)&amp;gt;} sale_id)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that for this to work, you must use chr(39) (single quote) outside the GetFieldSelections and not use double quotes in the {} set analysis, plus single quotes before and after the delimiter (as single quote would actually comment the code, you must use the escape method to identify the single quote as a string instead of a "function": ''','''&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/287708"&gt;@Clement15&lt;/a&gt;&amp;nbsp; thanks for your help&lt;/P&gt;</description>
    <pubDate>Thu, 04 Apr 2024 15:25:07 GMT</pubDate>
    <dc:creator>pedrohenriqueperna</dc:creator>
    <dc:date>2024-04-04T15:25:07Z</dc:date>
    <item>
      <title>Secondary filter to exclude values from measures</title>
      <link>https://community.qlik.com/t5/App-Development/Secondary-filter-to-exclude-values-from-measures/m-p/2437643#M97074</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a table for customer behavior analysis that the user can filter clothing brands and see data only for those who have purchased such brand, e.g NIKE.&lt;/P&gt;
&lt;P&gt;What I want to do is add an additional filter for exclusion: if the user has selected NIKE in the primary filter and ADIDAS in the secondary filter, it should show only data for customers that have bought NIKE but haven't bought ADIDAS.&lt;/P&gt;
&lt;P&gt;I've found some posts about the subject but I couldn't make it work. The closest I got was using alternate states to the exclusion filter and pointing out the state in the set analysis.&lt;/P&gt;
&lt;P&gt;What is the best way to achieve this?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 00:01:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Secondary-filter-to-exclude-values-from-measures/m-p/2437643#M97074</guid>
      <dc:creator>pedrohenriqueperna</dc:creator>
      <dc:date>2024-04-04T00:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Secondary filter to exclude values from measures</title>
      <link>https://community.qlik.com/t5/App-Development/Secondary-filter-to-exclude-values-from-measures/m-p/2437721#M97079</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Clement15_0-1712215494021.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/163407i8A4AE87E70DE5ACE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Clement15_0-1712215494021.png" alt="Clement15_0-1712215494021.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;For the second input variable you just have to choose another variable here vTest2.&lt;/P&gt;
&lt;P&gt;In the values the &amp;amp;'| ' after the Concat allows you to add an empty value allowing you to not have a filter&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 07:29:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Secondary-filter-to-exclude-values-from-measures/m-p/2437721#M97079</guid>
      <dc:creator>Clement15</dc:creator>
      <dc:date>2024-04-04T07:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Secondary filter to exclude values from measures</title>
      <link>https://community.qlik.com/t5/App-Development/Secondary-filter-to-exclude-values-from-measures/m-p/2437929#M97087</link>
      <description>&lt;P&gt;Hi, &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/287708"&gt;@Clement15&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to understand your solution, but I'm a bit confused, could you explain me some more?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Do I have to work with variable inputs in both cases? Or could I use a filter in the first case (or maybe in both)? I ask this, because the user might want to filter more than a brand (e.g customers that have bought Nike or Lacoste) and exclude another (possibly more than one brand as well, e.g: that haven't bought Adidas and CK)&lt;/P&gt;
&lt;P&gt;2. If I'm understanding it right, you're multiplying the P() by the E() in the expression, if that's right, why?&lt;/P&gt;
&lt;P&gt;3. What did you add to the variable? Is it a blank/null value and the values are then fulfilled with the Concat(Distinct Brand, '|')&amp;amp;'|'? If so, is this the complete expression in the dynamic values or is there more that is not being show in the picture?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 14:06:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Secondary-filter-to-exclude-values-from-measures/m-p/2437929#M97087</guid>
      <dc:creator>pedrohenriqueperna</dc:creator>
      <dc:date>2024-04-04T14:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Secondary filter to exclude values from measures</title>
      <link>https://community.qlik.com/t5/App-Development/Secondary-filter-to-exclude-values-from-measures/m-p/2438001#M97091</link>
      <description>&lt;P&gt;You gave me an insight using concat() and I managed to achieve what I wanted with a different approach. GetFieldSelections() will also concatenate the values and I can use it inside the set analysis&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For those who it might help, I used alternate states and getfieldselections:&lt;/P&gt;
&lt;P&gt;Filter 1 = product_brand (inherited state, no need for changes)&lt;/P&gt;
&lt;P&gt;Filter 2 (exclusion) = I created an alias field (product_brand_exc) and added a different state (e.g BrandExclusion) [maybe it's not necessary and you could use the same product_brand as it's using a different state]&lt;/P&gt;
&lt;P&gt;Then in the measure expression you could use GetFieldSelections() to retrieve the selected values in Filter 2:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Count(Distinct {&amp;lt;key_customer = E({BrandExclusion&amp;lt;product_brand = {$(=chr(39)&amp;amp;GetFieldSelections(product_brand_exc,''',''',10,'BrandExclusion')&amp;amp;chr(39))}&amp;gt;} key_customer)&amp;gt;} sale_id)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that for this to work, you must use chr(39) (single quote) outside the GetFieldSelections and not use double quotes in the {} set analysis, plus single quotes before and after the delimiter (as single quote would actually comment the code, you must use the escape method to identify the single quote as a string instead of a "function": ''','''&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/287708"&gt;@Clement15&lt;/a&gt;&amp;nbsp; thanks for your help&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 15:25:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Secondary-filter-to-exclude-values-from-measures/m-p/2438001#M97091</guid>
      <dc:creator>pedrohenriqueperna</dc:creator>
      <dc:date>2024-04-04T15:25:07Z</dc:date>
    </item>
  </channel>
</rss>

