<?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 Chart cost/unit with on a fixed aggregate unit count in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563499#M210279</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to chart sum(cost) / count(order) by day with the count of orders aggregated to a branch location.&amp;nbsp; The trick is how to aggregate the order count properly.&amp;nbsp; In the attached qvw, there are 3 locations, 5 orders, and cost amounts for a 7-day period.&amp;nbsp; The order volume for location 1 and 2 is 2, and for location 3 it is 1.&amp;nbsp; I want the cost per unit chart to express the daily cost for each location divided by the total orders for each location (e.g., Location 1 and 2 costs are divided by 2 each day, and Location 3 cost is divided by 1 every day).&amp;nbsp; I was able to express the units properly on day 1 only.&amp;nbsp; In order for the cost per unit chart to be expressed properly, I must not have empty values for subsequent days...&amp;nbsp; Thanks in advance for any advise you offer!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Jan 2014 21:06:21 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-01-23T21:06:21Z</dc:date>
    <item>
      <title>Chart cost/unit with on a fixed aggregate unit count</title>
      <link>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563499#M210279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to chart sum(cost) / count(order) by day with the count of orders aggregated to a branch location.&amp;nbsp; The trick is how to aggregate the order count properly.&amp;nbsp; In the attached qvw, there are 3 locations, 5 orders, and cost amounts for a 7-day period.&amp;nbsp; The order volume for location 1 and 2 is 2, and for location 3 it is 1.&amp;nbsp; I want the cost per unit chart to express the daily cost for each location divided by the total orders for each location (e.g., Location 1 and 2 costs are divided by 2 each day, and Location 3 cost is divided by 1 every day).&amp;nbsp; I was able to express the units properly on day 1 only.&amp;nbsp; In order for the cost per unit chart to be expressed properly, I must not have empty values for subsequent days...&amp;nbsp; Thanks in advance for any advise you offer!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jan 2014 21:06:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563499#M210279</guid>
      <dc:creator />
      <dc:date>2014-01-23T21:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Chart cost/unit with on a fixed aggregate unit count</title>
      <link>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563500#M210280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you just need to add the Day to the aggr:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum(Cost)&lt;/P&gt;&lt;P&gt;/&lt;/P&gt;&lt;P&gt;Aggr(Count(Distinct Order),Location,Day)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is that what you want?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jan 2014 21:26:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563500#M210280</guid>
      <dc:creator>Carlos_Reyes</dc:creator>
      <dc:date>2014-01-23T21:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: Chart cost/unit with on a fixed aggregate unit count</title>
      <link>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563501#M210281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In a chart, as long you have Day and location as the dimension, then sum(Cost) / count(order) will give you the desired result. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to hard code location 1 as count of 1 and location 2 and 3 as 2 then use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=if(Location =3,Sum(Cost)/1,sum(Cost)/2)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jan 2014 21:40:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563501#M210281</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-01-23T21:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Chart cost/unit with on a fixed aggregate unit count</title>
      <link>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563502#M210282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michael, thanks.&amp;nbsp; You would obtain the correct values with the latter hard-coded solution, but my data model has many locations and the order volume will change, so I need to have a dynamic calculation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;BTW, I could add &lt;/SPAN&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;LOAD Location, Count(DISTINCT Order)&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; &lt;/SPAN&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;As Volume&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; in the script as a second table and then use something like Max(Volume) in the chart expression denominator.&amp;nbsp; I would prefer to do the aggregation in the chart and avoid fixing the aggregation in the script though.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jan 2014 21:49:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563502#M210282</guid>
      <dc:creator />
      <dc:date>2014-01-23T21:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Chart cost/unit with on a fixed aggregate unit count</title>
      <link>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563503#M210283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah the only way I can think is in the Script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table1:&lt;/P&gt;&lt;P&gt;LOAD * INLINE [&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Day, Cost, Location, Order&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 40, 1, 1000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2, 100, 1, 1000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 150, 1, 1000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4, 200, 1, 1000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5, 250, 1, 1000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 30, 2, 2000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2, 50, 2, 2000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 100, 2, 2000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4, 120, 2, 2000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5, 150, 2, 2000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 30, 3, 3000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2, 50, 3, 3000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 50, 3, 3000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4, 80, 3, 3000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5, 100, 3, 3000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 45, 1, 1001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 105, 1, 1001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5, 155, 1, 1001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6, 205, 1, 1001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7, 255, 1, 1001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 35, 2, 2001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2, 55, 2, 2001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 105, 2, 2001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5, 125, 2, 2001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6, 155, 2, 2001&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD DISTINCT&lt;/P&gt;&lt;P&gt;Location,&lt;/P&gt;&lt;P&gt;Order as DistinctOrder&lt;/P&gt;&lt;P&gt;Resident Table1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The expression in the chart would be Sum(Cost)/Count(DistinctOrder)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jan 2014 22:24:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563503#M210283</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-01-23T22:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Chart cost/unit with on a fixed aggregate unit count</title>
      <link>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563504#M210284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Michael,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works, though it practically limits the fields I can use more than a solution within the chart expression would. Unfortunately it does not look like this can be done via a chart expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jan 2014 21:28:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563504#M210284</guid>
      <dc:creator />
      <dc:date>2014-01-24T21:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Chart cost/unit with on a fixed aggregate unit count</title>
      <link>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563505#M210285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The right aggregation approach is to use TOTAL and not aggr when aggregating a dimension.&amp;nbsp; Here is a discussion of the difference by &lt;A href="https://community.qlik.com/people/hic"&gt;hic&lt;/A&gt;:&amp;nbsp; &lt;A _jive_internal="true" href="https://community.qlik.com/blogs/qlikviewdesignblog/2013/09/09/aggregation-scope"&gt;http://community.qlik.com/blogs/qlikviewdesignblog/2013/09/09/aggregation-scope&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the discussion below the blog he points out that a dimensional scope may be included by adding a field reference after TOTAL so that the aggregation will disregard all dimensions except that field.&amp;nbsp; So, in my example, the expression should be &lt;STRONG&gt;Count(TOTAL &amp;lt;Location&amp;gt; Distinct Order)&lt;/STRONG&gt; to obtain a constant number of units by location over time.&amp;nbsp; This divided into cost provides the desired cost per unit result and chart.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution to this is attached. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Michael's script suggestion below is fine for the example, but the drawback I found with aggregating in script is that as more dimensions are added, the resulting tables become large, synthetic keys are created, and performance suffers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jan 2014 15:42:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Chart-cost-unit-with-on-a-fixed-aggregate-unit-count/m-p/563505#M210285</guid>
      <dc:creator />
      <dc:date>2014-01-27T15:42:29Z</dc:date>
    </item>
  </channel>
</rss>

