<?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 Subsets -- different calculations for a total field????? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Subsets-different-calculations-for-a-total-field/m-p/735315#M263165</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am attempting to use two different expressions within a subset of data.&amp;nbsp; The expressions are to derive an adjusted Cost and Quantity for specified lines of data within the set.&amp;nbsp; I am calculating cost and quantity, normally, by using the Cost and Quantity fields within my set. The adjusted calculations will need to reference other tables (“MaterialMaster” and “ComponentSubset”).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some problems I’ve come across are due to the 1 to Many relationships I have in my ComponentSubset table. Each Sub Material can but does not always have more than one Parent Material. Additionally, each Parent Material will have at least 2 Sub Materials associated but can have 3 in some cases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For all (&lt;EM&gt;Parent&lt;/EM&gt;) Materials in my dataset that equal a Parent material in my ComponetSubset table, the following formula is needed to calculate “&lt;STRONG&gt;&lt;EM&gt;Adjusted Cost&lt;/EM&gt;&lt;/STRONG&gt;”:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;Adjusted Cost&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; = Parent Qty * (Sub1 Standard Cost + Sub2 Standard Cost… + Sub3 Standard Cost (where necessary))&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;**Standard Cost can be found in the Material Master table via the MaterialPlant field.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For all (&lt;EM&gt;Sub&lt;/EM&gt;) Materials in my dataset that equal a Sub material in my ComponentSubet table, the following formula is needed to Calculate “&lt;STRONG&gt;&lt;EM&gt;Adjusted Quantity&lt;/EM&gt;&lt;/STRONG&gt;”:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;Adjusted Quantity&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; = Sub Quantity – Parent1 Quantity… - Parent2 Quantity (where necessary)&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ultimately, I am hoping to blend the normal Cost and Quantity calculation (reference Fields within dataset) with the adjusted calculations. &lt;/P&gt;&lt;UL style="list-style-type: disc;"&gt;&lt;LI&gt;All materials not included in the Parent field of the ComponentSubset table will use the Cost field from the dataset and all materials found in the Parent field will use the Adjusted Cost calculation to create a Total Cost field.&lt;/LI&gt;&lt;LI&gt;All materials &lt;SPAN style="text-decoration: underline;"&gt;NOT&lt;/SPAN&gt; included in the Sub field of the ComponentSubset table will use the Quantity field from the dataset and all materials found in the Sub field will use the Adjusted Quantity calculation to create a Total Quantity field.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;For example, to calculate the Adjusted Cost of (Parent) Material - 59012 and Adjusted Quantity of (Sub) Material – 59004:&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="border: none;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="padding: 0 5.4pt 0 5.4pt;" valign="top" width="319"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Parent Qty&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 15&lt;BR /&gt; Sub1 Standard Cost&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 55&lt;BR /&gt; &lt;SPAN style="text-decoration: underline;"&gt;Sub2 Standard Cost&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 95&lt;BR /&gt;&lt;/SPAN&gt; &lt;STRONG&gt;Adjusted Cost - 2250&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 15 * (55 + 95)&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 0 5.4pt 0 5.4pt;" valign="top" width="319"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Sub Quantity&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 40&lt;BR /&gt; Parent1 Qty&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 15&lt;BR /&gt; &lt;SPAN style="text-decoration: underline;"&gt;Parent2 Qty&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 15&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;Adjusted Quantity – 10&lt;/STRONG&gt; = 40 – 15 – 15&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I have attempted many different designs to accomplish these calculations but have not been able to complete everything I’ve needed yet. Originally, I tried using the aggr function to aggregate by Parent and/or Sub where applicable but could not figure it out completely.&amp;nbsp; I ha !ve since attempted to create temporary tables in the script, yet still have not been able to figure it out completey.&amp;nbsp; Attached is a qvw and an excel file with all data needed to simulate what I need.&amp;nbsp; Can anyone help, please??!!??!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Jul 2014 17:23:29 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-07-08T17:23:29Z</dc:date>
    <item>
      <title>Subsets -- different calculations for a total field?????</title>
      <link>https://community.qlik.com/t5/QlikView/Subsets-different-calculations-for-a-total-field/m-p/735315#M263165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am attempting to use two different expressions within a subset of data.&amp;nbsp; The expressions are to derive an adjusted Cost and Quantity for specified lines of data within the set.&amp;nbsp; I am calculating cost and quantity, normally, by using the Cost and Quantity fields within my set. The adjusted calculations will need to reference other tables (“MaterialMaster” and “ComponentSubset”).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some problems I’ve come across are due to the 1 to Many relationships I have in my ComponentSubset table. Each Sub Material can but does not always have more than one Parent Material. Additionally, each Parent Material will have at least 2 Sub Materials associated but can have 3 in some cases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For all (&lt;EM&gt;Parent&lt;/EM&gt;) Materials in my dataset that equal a Parent material in my ComponetSubset table, the following formula is needed to calculate “&lt;STRONG&gt;&lt;EM&gt;Adjusted Cost&lt;/EM&gt;&lt;/STRONG&gt;”:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;Adjusted Cost&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; = Parent Qty * (Sub1 Standard Cost + Sub2 Standard Cost… + Sub3 Standard Cost (where necessary))&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;**Standard Cost can be found in the Material Master table via the MaterialPlant field.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For all (&lt;EM&gt;Sub&lt;/EM&gt;) Materials in my dataset that equal a Sub material in my ComponentSubet table, the following formula is needed to Calculate “&lt;STRONG&gt;&lt;EM&gt;Adjusted Quantity&lt;/EM&gt;&lt;/STRONG&gt;”:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG style="font-size: 10pt; line-height: 1.5em;"&gt;Adjusted Quantity&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; = Sub Quantity – Parent1 Quantity… - Parent2 Quantity (where necessary)&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ultimately, I am hoping to blend the normal Cost and Quantity calculation (reference Fields within dataset) with the adjusted calculations. &lt;/P&gt;&lt;UL style="list-style-type: disc;"&gt;&lt;LI&gt;All materials not included in the Parent field of the ComponentSubset table will use the Cost field from the dataset and all materials found in the Parent field will use the Adjusted Cost calculation to create a Total Cost field.&lt;/LI&gt;&lt;LI&gt;All materials &lt;SPAN style="text-decoration: underline;"&gt;NOT&lt;/SPAN&gt; included in the Sub field of the ComponentSubset table will use the Quantity field from the dataset and all materials found in the Sub field will use the Adjusted Quantity calculation to create a Total Quantity field.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;For example, to calculate the Adjusted Cost of (Parent) Material - 59012 and Adjusted Quantity of (Sub) Material – 59004:&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="border: none;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="padding: 0 5.4pt 0 5.4pt;" valign="top" width="319"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Parent Qty&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 15&lt;BR /&gt; Sub1 Standard Cost&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 55&lt;BR /&gt; &lt;SPAN style="text-decoration: underline;"&gt;Sub2 Standard Cost&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 95&lt;BR /&gt;&lt;/SPAN&gt; &lt;STRONG&gt;Adjusted Cost - 2250&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 15 * (55 + 95)&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 0 5.4pt 0 5.4pt;" valign="top" width="319"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Sub Quantity&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 40&lt;BR /&gt; Parent1 Qty&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 15&lt;BR /&gt; &lt;SPAN style="text-decoration: underline;"&gt;Parent2 Qty&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 15&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;Adjusted Quantity – 10&lt;/STRONG&gt; = 40 – 15 – 15&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I have attempted many different designs to accomplish these calculations but have not been able to complete everything I’ve needed yet. Originally, I tried using the aggr function to aggregate by Parent and/or Sub where applicable but could not figure it out completely.&amp;nbsp; I ha !ve since attempted to create temporary tables in the script, yet still have not been able to figure it out completey.&amp;nbsp; Attached is a qvw and an excel file with all data needed to simulate what I need.&amp;nbsp; Can anyone help, please??!!??!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 17:23:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Subsets-different-calculations-for-a-total-field/m-p/735315#M263165</guid>
      <dc:creator />
      <dc:date>2014-07-08T17:23:29Z</dc:date>
    </item>
  </channel>
</rss>

