<?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 Exclude dimension value but don't respect selections in that dimension in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Exclude-dimension-value-but-don-t-respect-selections-in-that/m-p/1676784#M63727</link>
    <description>&lt;P&gt;I'll be honest, I don't really know how to title this one properly. I am working with a set of student test data with the following properties:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Every student has a unique ID&lt;/LI&gt;&lt;LI&gt;Every student may or may not have an Ethnicity assigned to them&lt;/LI&gt;&lt;LI&gt;Every student has a Gender&lt;/LI&gt;&lt;LI&gt;Every student takes either the Math test or the Reading test&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;My goal is to create a pivot table that does a side-by-side comparison of the count of students in an Ethnicity that took the test vs the count of students NOT in that Ethnicity that took the test. The table has 1 row dimension, 1 column dimension, and 2 measures (one for the count of students in the ethnicity and one for the count of students not in the ethnicity). About 2 months ago I asked a question on how to calculate a measure over the complement of the dimension value (&lt;A href="https://community.qlik.com/t5/Qlik-Sense-App-Development/Calculate-measure-over-complement-of-dimension-value/m-p/1661589#M49680" target="_blank" rel="noopener"&gt;https://community.qlik.com/t5/Qlik-Sense-App-Development/Calculate-measure-over-complement-of-dimension-value/m-p/1661589#M49680&lt;/A&gt;). This helped me to get the following expression for calculating the complement count of students for an ethnicity&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;pick(
    match(Ethnicity, $(='''' &amp;amp; concat(DISTINCT Ethnicity,''',''', Ethnicity) &amp;amp; '''')),
    $(=concat({$&amp;lt;Ethnicity -= {''}&amp;gt;} DISTINCT 'count({$&amp;lt;Student = E({$&amp;lt;Ethnicity = {''' &amp;amp; Ethnicity &amp;amp; '''}&amp;gt;} Student)&amp;gt;} TOTAL&amp;lt;Subject&amp;gt; DISTINCT Student)',',',Ethnicity))
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After the dollar-sign expansion, it results in the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=pick(match(Ethnicity, 'African American','Asian','Hispanic','White'),
  count({$&amp;lt;Student = E({$&amp;lt;Ethnicity = {'African American'}&amp;gt;} Student)&amp;gt;} TOTAL&amp;lt;Subject&amp;gt; DISTINCT Student),
  count({$&amp;lt;Student = E({$&amp;lt;Ethnicity = {'Asian'}&amp;gt;} Student)&amp;gt;} TOTAL&amp;lt;Subject&amp;gt; DISTINCT Student),
  count({$&amp;lt;Student = E({$&amp;lt;Ethnicity = {'Hispanic'}&amp;gt;} Student)&amp;gt;} TOTAL&amp;lt;Subject&amp;gt; DISTINCT Student),
  count({$&amp;lt;Student = E({$&amp;lt;Ethnicity = {'White'}&amp;gt;} Student)&amp;gt;} TOTAL&amp;lt;Subject&amp;gt; DISTINCT Student)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, for every dimension value (Ethnicity), it will create an expression that will include only the records where the Ethnicity is NOT that value.&amp;nbsp; The E() is used to account for students that do no have an Ethnicity assigned to them. And this works! The expression results in the following table (I've colored the cells to indicate the correct value):&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Complement_Set1.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/28596i88F8EC91BBCF7EA0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Complement_Set1.png" alt="Complement_Set1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, as soon as you select an Ethnicity:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Complement_Set2.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/28597iE1D66139060F4366/image-size/large?v=v2&amp;amp;px=999" role="button" title="Complement_Set2.png" alt="Complement_Set2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Because the expression uses the default state, any selection on the Ethnicity field results in a set of no records for the Exclusion. So I tried changing to the 1 state:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;pick(
    match(Ethnicity, $(='''' &amp;amp; concat(DISTINCT Ethnicity,''',''', Ethnicity) &amp;amp; '''')),
    $(=concat({$&amp;lt;Ethnicity -= {''}&amp;gt;} DISTINCT 'count({1&amp;lt;Student = E({1&amp;lt;Ethnicity = {''' &amp;amp; Ethnicity &amp;amp; '''}&amp;gt;} Student)&amp;gt;} TOTAL&amp;lt;Subject&amp;gt; DISTINCT Student)',',',Ethnicity))
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And now this works when I make a selection on Ethnicity:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Complement_Set3.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/28598i1EE7B84767647277/image-size/large?v=v2&amp;amp;px=999" role="button" title="Complement_Set3.PNG" alt="Complement_Set3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, when I make a selection on Gender, the number remains the same:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Complement_Set4.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/28599iD80B5633CF855D14/image-size/large?v=v2&amp;amp;px=999" role="button" title="Complement_Set4.PNG" alt="Complement_Set4.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This makes sense, because I am no longer including selections. What I want is for the expression to include the set limited by selections EXCEPT for Ethnicity. I've tried a few different methods but haven't found any success yet. I've attached my sample app to demonstrate this problem.&lt;BR /&gt;&lt;BR /&gt;Any help is appreciated.&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 03:14:03 GMT</pubDate>
    <dc:creator>dselgo_eidex</dc:creator>
    <dc:date>2024-11-16T03:14:03Z</dc:date>
    <item>
      <title>Exclude dimension value but don't respect selections in that dimension</title>
      <link>https://community.qlik.com/t5/App-Development/Exclude-dimension-value-but-don-t-respect-selections-in-that/m-p/1676784#M63727</link>
      <description>&lt;P&gt;I'll be honest, I don't really know how to title this one properly. I am working with a set of student test data with the following properties:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Every student has a unique ID&lt;/LI&gt;&lt;LI&gt;Every student may or may not have an Ethnicity assigned to them&lt;/LI&gt;&lt;LI&gt;Every student has a Gender&lt;/LI&gt;&lt;LI&gt;Every student takes either the Math test or the Reading test&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;My goal is to create a pivot table that does a side-by-side comparison of the count of students in an Ethnicity that took the test vs the count of students NOT in that Ethnicity that took the test. The table has 1 row dimension, 1 column dimension, and 2 measures (one for the count of students in the ethnicity and one for the count of students not in the ethnicity). About 2 months ago I asked a question on how to calculate a measure over the complement of the dimension value (&lt;A href="https://community.qlik.com/t5/Qlik-Sense-App-Development/Calculate-measure-over-complement-of-dimension-value/m-p/1661589#M49680" target="_blank" rel="noopener"&gt;https://community.qlik.com/t5/Qlik-Sense-App-Development/Calculate-measure-over-complement-of-dimension-value/m-p/1661589#M49680&lt;/A&gt;). This helped me to get the following expression for calculating the complement count of students for an ethnicity&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;pick(
    match(Ethnicity, $(='''' &amp;amp; concat(DISTINCT Ethnicity,''',''', Ethnicity) &amp;amp; '''')),
    $(=concat({$&amp;lt;Ethnicity -= {''}&amp;gt;} DISTINCT 'count({$&amp;lt;Student = E({$&amp;lt;Ethnicity = {''' &amp;amp; Ethnicity &amp;amp; '''}&amp;gt;} Student)&amp;gt;} TOTAL&amp;lt;Subject&amp;gt; DISTINCT Student)',',',Ethnicity))
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After the dollar-sign expansion, it results in the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=pick(match(Ethnicity, 'African American','Asian','Hispanic','White'),
  count({$&amp;lt;Student = E({$&amp;lt;Ethnicity = {'African American'}&amp;gt;} Student)&amp;gt;} TOTAL&amp;lt;Subject&amp;gt; DISTINCT Student),
  count({$&amp;lt;Student = E({$&amp;lt;Ethnicity = {'Asian'}&amp;gt;} Student)&amp;gt;} TOTAL&amp;lt;Subject&amp;gt; DISTINCT Student),
  count({$&amp;lt;Student = E({$&amp;lt;Ethnicity = {'Hispanic'}&amp;gt;} Student)&amp;gt;} TOTAL&amp;lt;Subject&amp;gt; DISTINCT Student),
  count({$&amp;lt;Student = E({$&amp;lt;Ethnicity = {'White'}&amp;gt;} Student)&amp;gt;} TOTAL&amp;lt;Subject&amp;gt; DISTINCT Student)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, for every dimension value (Ethnicity), it will create an expression that will include only the records where the Ethnicity is NOT that value.&amp;nbsp; The E() is used to account for students that do no have an Ethnicity assigned to them. And this works! The expression results in the following table (I've colored the cells to indicate the correct value):&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Complement_Set1.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/28596i88F8EC91BBCF7EA0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Complement_Set1.png" alt="Complement_Set1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, as soon as you select an Ethnicity:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Complement_Set2.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/28597iE1D66139060F4366/image-size/large?v=v2&amp;amp;px=999" role="button" title="Complement_Set2.png" alt="Complement_Set2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Because the expression uses the default state, any selection on the Ethnicity field results in a set of no records for the Exclusion. So I tried changing to the 1 state:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;pick(
    match(Ethnicity, $(='''' &amp;amp; concat(DISTINCT Ethnicity,''',''', Ethnicity) &amp;amp; '''')),
    $(=concat({$&amp;lt;Ethnicity -= {''}&amp;gt;} DISTINCT 'count({1&amp;lt;Student = E({1&amp;lt;Ethnicity = {''' &amp;amp; Ethnicity &amp;amp; '''}&amp;gt;} Student)&amp;gt;} TOTAL&amp;lt;Subject&amp;gt; DISTINCT Student)',',',Ethnicity))
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And now this works when I make a selection on Ethnicity:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Complement_Set3.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/28598i1EE7B84767647277/image-size/large?v=v2&amp;amp;px=999" role="button" title="Complement_Set3.PNG" alt="Complement_Set3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, when I make a selection on Gender, the number remains the same:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Complement_Set4.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/28599iD80B5633CF855D14/image-size/large?v=v2&amp;amp;px=999" role="button" title="Complement_Set4.PNG" alt="Complement_Set4.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This makes sense, because I am no longer including selections. What I want is for the expression to include the set limited by selections EXCEPT for Ethnicity. I've tried a few different methods but haven't found any success yet. I've attached my sample app to demonstrate this problem.&lt;BR /&gt;&lt;BR /&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 03:14:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Exclude-dimension-value-but-don-t-respect-selections-in-that/m-p/1676784#M63727</guid>
      <dc:creator>dselgo_eidex</dc:creator>
      <dc:date>2024-11-16T03:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude dimension value but don't respect selections in that dimension</title>
      <link>https://community.qlik.com/t5/App-Development/Exclude-dimension-value-but-don-t-respect-selections-in-that/m-p/1677224#M63728</link>
      <description>&lt;P&gt;So I spent two whole days working on this, and it turns out the correct number was three&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;.&lt;BR /&gt;&lt;BR /&gt;I actually had the answer before posting the question, but I was getting incorrect values. I figured that I could find the results that I wanted by finding the intersection of the default set excluding the selections on Ethnicity and the set of all students not in that ethnicity:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{$&amp;lt;Ethnicity = 1::Ethnicity&amp;gt; * 1&amp;lt;Student = E({1&amp;lt;Ethnicity = {''' &amp;amp; Ethnicity &amp;amp; '''}&amp;gt;} Student)&amp;gt;}&lt;/LI-CODE&gt;&lt;P&gt;Unfortunately though, this only includes non-null values for Ethnicity, meaning that my results were off. Through trial and error I got to this set expression:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{$&amp;lt;Ethnicity&amp;gt; * 1&amp;lt;Student = E({1&amp;lt;Ethnicity = {''' &amp;amp; Ethnicity &amp;amp; '''}&amp;gt;} Student)&amp;gt;}&lt;/LI-CODE&gt;&lt;P&gt;This finally worked! It passed all of my tests. However, when I loaded it into my actual app, it was incredibly slow because my actual pivot table has a few aggrs in it. I figured that the intersection of the sets was slowing things down, so I kept experimenting until I got this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{$&amp;lt;Ethnicity, Student = E({1&amp;lt;Ethnicity = {''' &amp;amp; Ethnicity &amp;amp; '''}&amp;gt;} Student)&amp;gt;}&lt;/LI-CODE&gt;&lt;P&gt;This created the same results as above, and was much faster to calculate.&lt;BR /&gt;&lt;BR /&gt;I posted the updated app to showcase these findings in case it helps anyone else with a similar problem.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 17:51:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Exclude-dimension-value-but-don-t-respect-selections-in-that/m-p/1677224#M63728</guid>
      <dc:creator>dselgo_eidex</dc:creator>
      <dc:date>2020-02-19T17:51:41Z</dc:date>
    </item>
  </channel>
</rss>

