<?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: Nested Aggr() function in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229805#M391956</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gysbert, that's spot on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm getting exactly the results I'm expecting across multiple departments, devices (and their specific unit costs).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll continue to test, but I'm confident that's it working exactly as intended.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks so much for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the sake of future visitors, this is the expression I have ended up with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;( &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[DeviceType]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;=&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;UnitCost&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)*( &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;TOTAL&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Department]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;Units&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;) / &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;count&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[DeviceType]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;={&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;"TypeA"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;}&amp;gt;} &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;DISTINCT&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;TOTAL&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Department]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;DeviceID&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)), &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;DeviceID&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Dec 2016 14:54:43 GMT</pubDate>
    <dc:creator />
    <dc:date>2016-12-08T14:54:43Z</dc:date>
    <item>
      <title>Nested Aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229797#M391948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hoping I could get some input on this - I've been stumped though I feel it should be fairly straightforward.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an expression currently looking like this (though evidently quite non-functional!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;Aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;UnitCost&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; * &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;UnitCount&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;) / &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;count&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;DISTINCT&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;DeviceID&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;) ,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Department]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;), Device&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)&lt;BR /&gt; ) &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;If it were related to a single device (DeviceID)&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; it would be as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;UnitCost * (Department Unit Count / Department Device Count)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;So I want the above expression to be carried out per device; each of their unique UnitCost values multiplied by unit department's average units per device. This all has to occur within a text object to provide a single total.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;The devices are added in the dashboard as a dynamic update, rather than as part of the reload. If the device count could be derived during the load script, I'd simply add a value against each department of their "Average Units Per Device" and it would be a little more straightforward.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I feel I'm missing something obvious; if anyone can provide a little input that would be great.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Thanks in advance!!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 12:36:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229797#M391948</guid>
      <dc:creator />
      <dc:date>2016-12-08T12:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229798#M391949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;Perhaps like this: &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;sum( aggr( sum( UnitCost ) * sum(TOTAL &amp;lt;Department&amp;gt; UnitCount) / count(DISTINCT TOTAL &amp;lt;Department&amp;gt; &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;DeviceID&lt;/SPAN&gt;), UnitIdentifierHere ) )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;If not, please post a small Qlikview document with example data that demonstrates the problem.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 12:41:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229798#M391949</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2016-12-08T12:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229799#M391950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are nesting aggr() without an aggregation and this shouldn't work (properly). I think you could try something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;Aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;UnitCost&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; * &lt;STRONG&gt;avg&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;UnitCount&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;) / &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;count&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;DISTINCT&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;DeviceID&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;) ,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Department]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)&lt;STRONG&gt;)&lt;/STRONG&gt;, Device&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)&lt;BR /&gt; ) &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 12:43:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229799#M391950</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2016-12-08T12:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229800#M391951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May be this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum(Aggr(UnitCost * (Sum(UnitCount)/Count(DeviceID)), Department, DeviceID))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 12:45:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229800#M391951</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-12-08T12:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229801#M391952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=sum( aggr(sum(UnitCost)*( sum(TOTAL &amp;lt;Department&amp;gt; UnitCount) / count(TOTAL &amp;lt;Department&amp;gt; DISTINCT DeviceID)), DeviceID, Department))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 13:41:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229801#M391952</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-12-08T13:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229802#M391953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gysbert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think that's on the right track - as well as Payal's response below. I'm not getting the exact numbers I expect as I need to select a subset of a particular departments devices..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The use of &amp;lt;Department&amp;gt; is new to me; could you possibly explain just what that is doing? Also, can I add additional set modifers to it? I didn't include the set analysis in my original request because I didn't want to overcomplicate where unnecessary, but I'd need it something along the lines of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: Helvetica;"&gt;count(DISTINCT TOTAL &amp;lt;Department, DeviceType={"TypeA"}&amp;gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.33px;"&gt;DeviceID&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: Helvetica;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: Helvetica;"&gt;so I assume I'd maybe remove the TOTAL keyword also?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: Helvetica;"&gt;Thanks!!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 14:30:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229802#M391953</guid>
      <dc:creator />
      <dc:date>2016-12-08T14:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229803#M391954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this: count({&amp;lt;DeviceType={"TypeA"}&amp;gt;} DISTINCT TOTAL &amp;lt;Department&amp;gt; DeviceID)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 14:33:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229803#M391954</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2016-12-08T14:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229804#M391955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For individual department try below option&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=sum({&amp;lt;Department={'Dept1'}&amp;gt;} UnitCost) * (sum( {&amp;lt;Department={'Dept1'}&amp;gt;} UnitCount) / count( {&amp;lt;Department={'Dept1'}&amp;gt;} DISTINCT DeviceID)) &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 14:43:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229804#M391955</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-12-08T14:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229805#M391956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gysbert, that's spot on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm getting exactly the results I'm expecting across multiple departments, devices (and their specific unit costs).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll continue to test, but I'm confident that's it working exactly as intended.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks so much for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the sake of future visitors, this is the expression I have ended up with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;( &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[DeviceType]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;=&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;UnitCost&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)*( &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;TOTAL&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Department]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;Units&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;) / &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;count&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[DeviceType]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;={&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;"TypeA"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;}&amp;gt;} &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;DISTINCT&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;TOTAL&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Department]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;DeviceID&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)), &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;DeviceID&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 14:54:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229805#M391956</guid>
      <dc:creator />
      <dc:date>2016-12-08T14:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229806#M391957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Payal, for this response and your previous response below! I used Gysbert's solution, however with a little testing, it looks like yours worked too and with the same modifications above would likely have worked equally well as a solution. Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 15:03:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229806#M391957</guid>
      <dc:creator />
      <dc:date>2016-12-08T15:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229807#M391958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your response Marcus!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're right, I was missing an aggregation!! D'oh!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your solution wasn't yielding quite the results I expected though I'm not sure why; it looks good! Thanks for your response!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 15:06:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229807#M391958</guid>
      <dc:creator />
      <dc:date>2016-12-08T15:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229808#M391959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply, Sunny! I went with Gysbert's answer as I think it covered the requirement for looking at the TOTAL devices in a department, however I think your solution would have worked if I modified it to my requirements a bit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Appreciate you answering my question - Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 15:13:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-Aggr-function/m-p/1229808#M391959</guid>
      <dc:creator />
      <dc:date>2016-12-08T15:13:29Z</dc:date>
    </item>
  </channel>
</rss>

