<?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: Comparing data with result of another aggregation in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Comparing-data-with-result-of-another-aggregation/m-p/1522753#M37495</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;&lt;PRE&gt;Count(
	Aggr(
    	If(
        	Avg(TOTAL &amp;lt;station&amp;gt; {1&amp;lt;date={"$(vDate1)"}&amp;gt;}[discount]) &amp;gt;= ($(vTarget)-$(vOffset))
    	    and
	        Avg(TOTAL &amp;lt;station&amp;gt; {1&amp;lt;date={"$(vDate1)"}&amp;gt;}[discount]) &amp;lt;= ($(vTarget)+$(vOffset))
            and
            Avg(TOTAL &amp;lt;station&amp;gt; {1&amp;lt;date={"$(vDate1)"}&amp;gt;}[discount]) &amp;gt; Avg({1&amp;lt;date={"$(vDate2)"}&amp;gt;}[discount])
        , station)
	, station, date)
)&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Dec 2018 20:37:34 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2018-12-19T20:37:34Z</dc:date>
    <item>
      <title>Comparing data with result of another aggregation</title>
      <link>https://community.qlik.com/t5/App-Development/Comparing-data-with-result-of-another-aggregation/m-p/1522741#M37494</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;My data model consists of date, station and discount. So, for any given date, a station has a discount.&lt;/P&gt;&lt;P&gt;In my app, the user can select Date1, Date2, Target discount and discount offset. These values are stored in variables. The target and offset are used for determining a discount range: target +/- offset. &amp;nbsp;In the screenshot, the discount range is 8-12 (target=10, offset= +/-2)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2018-12-19 at 21.02.11.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/2437i9160B8B567CF0707/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2018-12-19 at 21.02.11.png" alt="Screen Shot 2018-12-19 at 21.02.11.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;have identified the number of stations that for Date1 has discounts that are within the discount boundary.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2018-12-19 at 21.02.20.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/2439iD433B8542035A182/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2018-12-19 at 21.02.20.png" alt="Screen Shot 2018-12-19 at 21.02.20.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using this expression in the "On Target" measure:&lt;/P&gt;&lt;PRE&gt;Count(
   Aggr(
      If(
         Avg({1&amp;lt;date={"$(vDate1)"}&amp;gt;}[discount]) &amp;gt;= ($(vTarget)-$(vOffset))
         and
         Avg({1&amp;lt;date={"$(vDate1)"}&amp;gt;}[discount]) &amp;lt;= ($(vTarget)+$(vOffset))
      , station)
   , station))&lt;/PRE&gt;&lt;P&gt;Now, I wish to count the number of stations that was&amp;nbsp;in the discount range on Date1 AND has a discount on Date2 which is lower than it was on Date1. My resulting table looks like:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2018-12-19 at 21.02.16.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/2438i78CD3A816197D0C4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2018-12-19 at 21.02.16.png" alt="Screen Shot 2018-12-19 at 21.02.16.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So, for the row with date=2018-01-02, I would expect "# lower" to be 1, since station S3 was within the discount range on Date1 AND its discount on Date2 is lower than it was on Date1.&lt;/P&gt;&lt;P&gt;I need some kind of AGGR magic here, but so far I have not been able to figure it out myself. I have also attached the app.&lt;/P&gt;&lt;P&gt;Hope someone can help! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;Rasmus&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 07:00:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Comparing-data-with-result-of-another-aggregation/m-p/1522741#M37494</guid>
      <dc:creator>rasmusnielsen</dc:creator>
      <dc:date>2024-11-16T07:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing data with result of another aggregation</title>
      <link>https://community.qlik.com/t5/App-Development/Comparing-data-with-result-of-another-aggregation/m-p/1522753#M37495</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;PRE&gt;Count(
	Aggr(
    	If(
        	Avg(TOTAL &amp;lt;station&amp;gt; {1&amp;lt;date={"$(vDate1)"}&amp;gt;}[discount]) &amp;gt;= ($(vTarget)-$(vOffset))
    	    and
	        Avg(TOTAL &amp;lt;station&amp;gt; {1&amp;lt;date={"$(vDate1)"}&amp;gt;}[discount]) &amp;lt;= ($(vTarget)+$(vOffset))
            and
            Avg(TOTAL &amp;lt;station&amp;gt; {1&amp;lt;date={"$(vDate1)"}&amp;gt;}[discount]) &amp;gt; Avg({1&amp;lt;date={"$(vDate2)"}&amp;gt;}[discount])
        , station)
	, station, date)
)&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Dec 2018 20:37:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Comparing-data-with-result-of-another-aggregation/m-p/1522753#M37495</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-12-19T20:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing data with result of another aggregation</title>
      <link>https://community.qlik.com/t5/App-Development/Comparing-data-with-result-of-another-aggregation/m-p/1522865#M37509</link>
      <description>Must simpler than I had imagined!&lt;BR /&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 20 Dec 2018 08:30:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Comparing-data-with-result-of-another-aggregation/m-p/1522865#M37509</guid>
      <dc:creator>rasmusnielsen</dc:creator>
      <dc:date>2018-12-20T08:30:32Z</dc:date>
    </item>
  </channel>
</rss>

