<?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 How to use set analysis to select records excluded from the aggregation scope in a chart??? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/How-to-use-set-analysis-to-select-records-excluded-from-the/m-p/1784806#M64327</link>
    <description>&lt;P&gt;Greetings!&lt;/P&gt;&lt;P&gt;I am trying to use the E() function to select excluded records for the current aggregation scope in a regular table chart and I am wondering if someone else has run into issues similar to what I describe below.&amp;nbsp; The Purpose of the char is to have a report containing Order, Product &amp;amp; Price dimensions as well as a measure containing the avg price of the same product in all other orders (that is, not considering the current one).&amp;nbsp; Think of it as a naive price anomaly detection calculation.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jdiaz_0-1614004117083.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/49568iAA076E90850D6092/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jdiaz_0-1614004117083.png" alt="jdiaz_0-1614004117083.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I initially tried to use the E() function to have the calculation done on other Orders, as in &lt;EM&gt;Avg({$&amp;lt;Order=E(Order)&amp;gt;} Price)&lt;/EM&gt;, but, as can be seen in the image above, it didn't work in this visualization.&amp;nbsp; However, it works when a visualization does not include Order in the aggregation scope and one selects an Order via the Sense UI (as shown in the second table below).&amp;nbsp; The problem with this second approach is that this would require the user to select one order at a time via the Sense UI.&amp;nbsp; My understanding is that this happens because the Order dimension is in the aggregation scope of the chart above, but not in the second chart below.&amp;nbsp; I also tried to use different options for the field selector for Order (such as O&lt;EM&gt;rder = P({1} Order) - Order&lt;/EM&gt;), but none of them worked.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jdiaz_1-1614006056200.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/49572i632473539A1AD45E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jdiaz_1-1614006056200.png" alt="jdiaz_1-1614006056200.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Since I just needed to calculate an average of the same products in other orders, I ended up using the following expression &lt;EM&gt;(sum({$&amp;lt;Order=&amp;gt;} TOTAL&amp;lt;Product&amp;gt; Price) - Price ) / (count({$&amp;lt;Order=&amp;gt;} TOTAL&amp;lt;Product&amp;gt; Price) - 1)&lt;/EM&gt;, which sort of solves the problem at hand.&amp;nbsp; However, it seems to me that there must be better and easier ways to do this, since getting the proper results would require a very complex expression in other situations, such as for a requirement to calculate if a price falls within a standard deviation of the prices for the same product in other orders, or some such.&lt;/P&gt;&lt;P&gt;So, my question is: using set analysis, how does one use the current value of dimensions in the aggregation scope of a chart to select records that have dimension values completely &lt;U&gt;excluded&lt;/U&gt; from at least a portion of that current scope?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attaching a test QVF in case anyone wants to play with it.&lt;/P&gt;&lt;P&gt;Please advise.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;++José&lt;/P&gt;</description>
    <pubDate>Mon, 20 Dec 2021 21:05:46 GMT</pubDate>
    <dc:creator>diagonjope</dc:creator>
    <dc:date>2021-12-20T21:05:46Z</dc:date>
    <item>
      <title>How to use set analysis to select records excluded from the aggregation scope in a chart???</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-use-set-analysis-to-select-records-excluded-from-the/m-p/1784806#M64327</link>
      <description>&lt;P&gt;Greetings!&lt;/P&gt;&lt;P&gt;I am trying to use the E() function to select excluded records for the current aggregation scope in a regular table chart and I am wondering if someone else has run into issues similar to what I describe below.&amp;nbsp; The Purpose of the char is to have a report containing Order, Product &amp;amp; Price dimensions as well as a measure containing the avg price of the same product in all other orders (that is, not considering the current one).&amp;nbsp; Think of it as a naive price anomaly detection calculation.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jdiaz_0-1614004117083.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/49568iAA076E90850D6092/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jdiaz_0-1614004117083.png" alt="jdiaz_0-1614004117083.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I initially tried to use the E() function to have the calculation done on other Orders, as in &lt;EM&gt;Avg({$&amp;lt;Order=E(Order)&amp;gt;} Price)&lt;/EM&gt;, but, as can be seen in the image above, it didn't work in this visualization.&amp;nbsp; However, it works when a visualization does not include Order in the aggregation scope and one selects an Order via the Sense UI (as shown in the second table below).&amp;nbsp; The problem with this second approach is that this would require the user to select one order at a time via the Sense UI.&amp;nbsp; My understanding is that this happens because the Order dimension is in the aggregation scope of the chart above, but not in the second chart below.&amp;nbsp; I also tried to use different options for the field selector for Order (such as O&lt;EM&gt;rder = P({1} Order) - Order&lt;/EM&gt;), but none of them worked.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jdiaz_1-1614006056200.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/49572i632473539A1AD45E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jdiaz_1-1614006056200.png" alt="jdiaz_1-1614006056200.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Since I just needed to calculate an average of the same products in other orders, I ended up using the following expression &lt;EM&gt;(sum({$&amp;lt;Order=&amp;gt;} TOTAL&amp;lt;Product&amp;gt; Price) - Price ) / (count({$&amp;lt;Order=&amp;gt;} TOTAL&amp;lt;Product&amp;gt; Price) - 1)&lt;/EM&gt;, which sort of solves the problem at hand.&amp;nbsp; However, it seems to me that there must be better and easier ways to do this, since getting the proper results would require a very complex expression in other situations, such as for a requirement to calculate if a price falls within a standard deviation of the prices for the same product in other orders, or some such.&lt;/P&gt;&lt;P&gt;So, my question is: using set analysis, how does one use the current value of dimensions in the aggregation scope of a chart to select records that have dimension values completely &lt;U&gt;excluded&lt;/U&gt; from at least a portion of that current scope?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attaching a test QVF in case anyone wants to play with it.&lt;/P&gt;&lt;P&gt;Please advise.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;++José&lt;/P&gt;</description>
      <pubDate>Mon, 20 Dec 2021 21:05:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-use-set-analysis-to-select-records-excluded-from-the/m-p/1784806#M64327</guid>
      <dc:creator>diagonjope</dc:creator>
      <dc:date>2021-12-20T21:05:46Z</dc:date>
    </item>
  </channel>
</rss>

