<?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: Aggregating using an expression as a dimension in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057910#M354485</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understood correctly, fractile() won't help here, it's really more like a pareto analysis with multiple bands.&lt;/P&gt;&lt;P&gt;(Well, maybe I am wrong) I believe the buckets won't show similar number of margin values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you can use an advanced aggregation to create your 0-7 buckets based on Margin field (you need to have a margin &lt;EM&gt;field &lt;/EM&gt;to make this approach work, no expression for margin calculation. I understood you have a margin field, right?).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I struggled a bit with your data showing some records with no numeric margin, in your sample it's sorted last in the table, so I tried to do the same (note if you remove these records from your selection or if you order these records first in your table for accumulated spend, the found min margin will of course change).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution attached works in QV12 using the new StructuredParameter for aggr() dimension sorting.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/qlik-blogpost/4673"&gt;The sortable Aggr function is finally here!&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should also work with QV11.20, if you manage to sort the load order of margin field accordingly (like discussed in ref. blog post).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 12 Mar 2016 01:08:14 GMT</pubDate>
    <dc:creator>swuehl</dc:creator>
    <dc:date>2016-03-12T01:08:14Z</dc:date>
    <item>
      <title>Aggregating using an expression as a dimension</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057907#M354482</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 you can help me, I've got stuck on what I think is an aggregation issue. My issue is that I think in order to get the result I'm looking for I need to do an aggregation using one of the expressions I've already calculated in the table as a dimension value and I'm not sure if this is possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So to explain, I have sales (aka spend) data which is bucketed by margin value, below is a snippet...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="117724" alt="Qlik1.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/117724_Qlik1.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;What I want to do is 'bucket' this spend into 8 equal spend amounts then find the min margin for that bucket. So first I accumulate the spend and then put an accumulated percentage against that spend. Using that percentile I can tell which bucket it is in (as each bucket is 12.5%). So I now have a bucket of 0 to 7. All good so far...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="117732" alt="Qlik2.PNG" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/117732_Qlik2.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;I then want to use that 'Bucket' to find what the min Margin is for each bucket. This is where I am stuck as the 'Bucket' is a calculated field and so I can't use it in an aggregation. I've attached a qvw example where in the dataset I've added the bucket as part of the dataset to show it can be done when it is a dimension. But in my real data I don't have bucket and it has to be dynamically calculated based on selections so can't be done in the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My end goal is to try and just have a table with the 8 buckets and the bucket margin as per below..&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="117733" alt="Final Table.PNG" class="jive-image image-3" src="/legacyfs/online/117733_Final Table.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Can anyone help please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My thanks in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Derek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Mar 2016 15:59:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057907#M354482</guid>
      <dc:creator>derekjones</dc:creator>
      <dc:date>2016-03-11T15:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating using an expression as a dimension</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057908#M354483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't quite follow what you're after, but I'm guessing you're going to need the fractile function. See for example this blog post: &lt;A href="http://www.qlikfix.com/2010/10/08/decile-analysis/" title="http://www.qlikfix.com/2010/10/08/decile-analysis/"&gt;Decile analysis - The Qlik Fix!&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Mar 2016 16:25:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057908#M354483</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2016-03-11T16:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating using an expression as a dimension</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057909#M354484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Gysbert&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From an initial glance at Barry Harmsen's blog it could be what I'm after. I'll let the community know if it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for the point in the right direction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Derek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Mar 2016 16:35:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057909#M354484</guid>
      <dc:creator>derekjones</dc:creator>
      <dc:date>2016-03-11T16:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating using an expression as a dimension</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057910#M354485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understood correctly, fractile() won't help here, it's really more like a pareto analysis with multiple bands.&lt;/P&gt;&lt;P&gt;(Well, maybe I am wrong) I believe the buckets won't show similar number of margin values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you can use an advanced aggregation to create your 0-7 buckets based on Margin field (you need to have a margin &lt;EM&gt;field &lt;/EM&gt;to make this approach work, no expression for margin calculation. I understood you have a margin field, right?).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I struggled a bit with your data showing some records with no numeric margin, in your sample it's sorted last in the table, so I tried to do the same (note if you remove these records from your selection or if you order these records first in your table for accumulated spend, the found min margin will of course change).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution attached works in QV12 using the new StructuredParameter for aggr() dimension sorting.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/qlik-blogpost/4673"&gt;The sortable Aggr function is finally here!&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should also work with QV11.20, if you manage to sort the load order of margin field accordingly (like discussed in ref. blog post).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Mar 2016 01:08:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057910#M354485</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2016-03-12T01:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating using an expression as a dimension</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057911#M354486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Attached the QV11.20 version of the advanced aggregation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I noticed that the load order of your margin field values is already sorted ascending, so if you manage to create your input table like you already did for this sample, sorted by margin ascending, you are done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your source differs and you need to sort in QV, you can do i like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14577760453755915" jivemacro_uid="_14577760453755915" modifiedtitle="true"&gt;
&lt;P&gt;YourSource:&lt;/P&gt;
&lt;P&gt;LOAD Margin, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Spend, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Accum Spend], &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Percentile, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Bucket&lt;/P&gt;
&lt;P&gt;FROM&lt;/P&gt;
&lt;P&gt;&lt;I&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;(biff, embedded labels);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;SORT:&lt;/P&gt;
&lt;P&gt;LOAD *, Margin as MarginSorted&lt;/P&gt;
&lt;P&gt;RESIDENT YourSource&lt;/P&gt;
&lt;P&gt;ORDER BY Margin;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;DROP TABLE YourSource;&lt;/P&gt;
&lt;P&gt;DROP FIELD Margin;&lt;/P&gt;
&lt;P&gt;Rename Field MarginSorted to Margin;&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Mar 2016 09:51:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057911#M354486</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2016-03-12T09:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating using an expression as a dimension</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057912#M354487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Stefan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes you were right, the fractile(), although an interesting concept in itself, would not have solved my problem. Your solution works a treat with the data I provided and unfortunately we've not yet upgraded to 12 so I will have to sort the data in the load. I've done some initial tests and it seems to hang together. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One question, in your expression for the dimension, you have used 'Sum(TOTAL Spend)-1E-10', what is the purpose of -1E-10 doing as I've not seen this before and I can't work it out?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for your assistance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Derek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2016 11:00:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057912#M354487</guid>
      <dc:creator>derekjones</dc:creator>
      <dc:date>2016-03-14T11:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating using an expression as a dimension</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057913#M354488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It subtracts 10 to the power of -10, a very small number, from the quotient / percentage. because I noticed that the bucketing used in the dimension does create a bucket '8' otherwise, with the last margin value that fills up to 100%. I think this is a rounding issue, it should not do this logical wise.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AFAIR I used a different method in the other chart using RangeMin() to limit the max bucket number to 7. Since this does only affect bucket 7+, maybe this is the preferred method to cope with the rounding issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2016 12:03:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-using-an-expression-as-a-dimension/m-p/1057913#M354488</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2016-03-14T12:03:12Z</dc:date>
    </item>
  </channel>
</rss>

