<?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 How can I do this calculation? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145298#M24031</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's not set analysis. You're allowed to total across the value of a particular field or list of fields. It's something I tend to forget and have to keep reminding myself of.&lt;/P&gt;&lt;P&gt;sum( [{set_expression}] [ distinct ] [ total [&amp;lt;fld {, fld}&amp;gt;] ] expression )&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 May 2009 03:47:14 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2009-05-28T03:47:14Z</dc:date>
    <item>
      <title>How can I do this calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145291#M24024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have to make a calculation that shows me for each sales order, how much is the freight charge.&lt;/P&gt;&lt;P&gt;The problem is that for each transportation made, I can find more than one sales order associated, and when it occurs, I have to calculate the corresponding freight charge according with the weight of the products for the sales order, and I have no idea how can I do this using Qlik View.&lt;/P&gt;&lt;P&gt;Here are the tables that I have:&lt;/P&gt;&lt;P&gt;Freight Document&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Freight Number (key)&lt;/LI&gt;&lt;LI&gt;Amount&lt;/LI&gt;&lt;LI&gt;Weight&lt;/LI&gt;&lt;/UL&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Sales Order&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Order Number (key)&lt;/LI&gt;&lt;LI&gt;Freight Number (key)&lt;/LI&gt;&lt;LI&gt;Weight&lt;/LI&gt;&lt;/UL&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;In a normal application, I'd read all sales order for each freight document, and make the prorate according to the sales order weight to find the corresponding amount, and then I could know the corresponding freight amount for each sales order.&lt;/P&gt;&lt;P&gt;Anyone can give me a help to do that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2009 02:36:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145291#M24024</guid>
      <dc:creator>rcandeo</dc:creator>
      <dc:date>2009-05-28T02:36:45Z</dc:date>
    </item>
    <item>
      <title>How can I do this calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145292#M24025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure I completely understand, but I'm thinking that once joined, you will essentially have a table with 5 fields, two of those being weight. Multiple Sales make up each Freight. Is the Freight Amount a simple calculation (i.e. 1 kg = a certain dollar amount or half the weight pays half the freight)?&lt;/P&gt;&lt;P&gt;If you have a freight with 3 sales, then that freight has a weight of those three sales weights combined. From that, you can get a percentage of the freight, which you could multiply against the freight amount to get amount for each sale.&lt;/P&gt;&lt;P&gt;In a chart:&lt;/P&gt;&lt;P&gt;Sales Order (Dim)&lt;/P&gt;&lt;P&gt;Freight Number (Dim)&lt;/P&gt;&lt;P&gt;Freight Weight (Dim)&lt;/P&gt;&lt;P&gt;Frieght Amount (Dim)&lt;/P&gt;&lt;P&gt;Percentage of Freight ( Weight / "Freight Weight")&lt;/P&gt;&lt;P&gt;Amount for this Sale ( "Percentage of Freight" * "Freight Amount")&lt;/P&gt;&lt;P&gt;Am I missing a piece?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2009 02:54:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145292#M24025</guid>
      <dc:creator />
      <dc:date>2009-05-28T02:54:39Z</dc:date>
    </item>
    <item>
      <title>How can I do this calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145293#M24026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I should have made an example, and I found out that I don't need Weight field in Freight Document Table, sorry. Here is an example:&lt;/P&gt;&lt;P&gt;Freight Document table&lt;/P&gt;&lt;P&gt;Freight Number = 200&lt;/P&gt;&lt;P&gt;Amount = $5,000&lt;/P&gt;&lt;P&gt;Weight = 10,000 kg&lt;/P&gt;&lt;P&gt;Sales Order Table Record number 1&lt;/P&gt;&lt;P&gt;Order Number = 11&lt;/P&gt;&lt;P&gt;Freight Number = 200&lt;/P&gt;&lt;P&gt;Weight = 8,000 kg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sales Order Table Record number 2&lt;/P&gt;&lt;P&gt;Order Number = 12&lt;/P&gt;&lt;P&gt;Freight Number = 200&lt;/P&gt;&lt;P&gt;Weight = 1,000 kg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sales Order Table Record number 3&lt;/P&gt;&lt;P&gt;Order Number = 13&lt;/P&gt;&lt;P&gt;Freight Number = 200&lt;/P&gt;&lt;P&gt;Weight = 1,500 kg&lt;/P&gt;&lt;P style="font-weight: bold"&gt;The calculation that I have to do is:&lt;/P&gt;&lt;P&gt;Sales Order Weight / sum(Sales Order Weight) * Amount&lt;/P&gt;&lt;P&gt;For Order Number 11 = 8,000 / 10,500 * 5,000 = 3,809.52&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My result must be:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Order Number 11 = 3,809.52&lt;/P&gt;&lt;P&gt;Order Number 12 = 476.19&lt;/P&gt;&lt;P&gt;Order Number 13 = 714.29&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2009 03:14:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145293#M24026</guid>
      <dc:creator>rcandeo</dc:creator>
      <dc:date>2009-05-28T03:14:25Z</dc:date>
    </item>
    <item>
      <title>How can I do this calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145294#M24027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you need an aggr() function to calculate the total weight of the freight. Aggr( Sum(Weight), Freight Number)&lt;/P&gt;&lt;P&gt;I'm going to plug your numbers into a simple app and try to put together a sample.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2009 03:18:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145294#M24027</guid>
      <dc:creator />
      <dc:date>2009-05-28T03:18:53Z</dc:date>
    </item>
    <item>
      <title>How can I do this calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145295#M24028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This maybe?&lt;/P&gt;&lt;P&gt;sum(Amount) * sum(Weight) / sum(total &amp;lt;"Freight Number"&amp;gt; Weight)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2009 03:24:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145295#M24028</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2009-05-28T03:24:22Z</dc:date>
    </item>
    <item>
      <title>How can I do this calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145296#M24029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That seems to do it John. Is that considered Set Analysis? I haven't seen brackets with only a field name used like that before.&lt;/P&gt;&lt;P&gt;I tried using this: =(Weight / Aggr(Sum (Weight), FreightNumber)) * Amount but that only seemed to work for one field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2009 03:41:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145296#M24029</guid>
      <dc:creator />
      <dc:date>2009-05-28T03:41:02Z</dc:date>
    </item>
    <item>
      <title>How can I do this calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145297#M24030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think the answers will help me too much. The only thing is that I need to find out where I put this calculation, since I have a huge application generating a QVD file, and I need to make this calculation in the script, where I have the sales order number and need to get the freight amount.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2009 03:45:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145297#M24030</guid>
      <dc:creator>rcandeo</dc:creator>
      <dc:date>2009-05-28T03:45:40Z</dc:date>
    </item>
    <item>
      <title>How can I do this calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145298#M24031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's not set analysis. You're allowed to total across the value of a particular field or list of fields. It's something I tend to forget and have to keep reminding myself of.&lt;/P&gt;&lt;P&gt;sum( [{set_expression}] [ distinct ] [ total [&amp;lt;fld {, fld}&amp;gt;] ] expression )&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2009 03:47:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145298#M24031</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2009-05-28T03:47:14Z</dc:date>
    </item>
    <item>
      <title>How can I do this calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145299#M24032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think doing it in the script would be easier. Are you reading these from a database table? If so, you could use a nested SQL statement.&lt;/P&gt;&lt;P&gt;SELECT SalesNumber, FreightNumber, Weight, TotalFreightWeight&lt;/P&gt;&lt;P&gt;FROM SalesTbl INNER JOIN (SELECT FreightNumber, Sum(Weight) as TotalFreightWeight FROM SalesTbl GROUP BY FreightNumber) As FreightWeight&lt;/P&gt;&lt;P&gt;ON SalesTbl.FreightNumber = FreightWeight.FreightNumber&lt;/P&gt;&lt;P&gt;Something like that, but I haven't been hand writing a lot of SQL lately.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2009 03:55:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145299#M24032</guid>
      <dc:creator />
      <dc:date>2009-05-28T03:55:26Z</dc:date>
    </item>
    <item>
      <title>How can I do this calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145300#M24033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks John! This one is going on a note on my bulletin board.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2009 03:56:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145300#M24033</guid>
      <dc:creator />
      <dc:date>2009-05-28T03:56:31Z</dc:date>
    </item>
    <item>
      <title>How can I do this calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145301#M24034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you're instead loading from QVDs or other existing QlikView tables, I think it gets a bit more involved, since you can only load from one table at a time. Here's one approach:&lt;/P&gt;&lt;P&gt;LEFT JOIN ([Freight Document])&lt;BR /&gt;LOAD&lt;BR /&gt; "Freight Number"&lt;BR /&gt;,sum("Weight") as "Freight Weight"&lt;BR /&gt;RESIDENT [Sales Order]&lt;BR /&gt;GROUP BY "Freight Number"&lt;BR /&gt;;&lt;BR /&gt;[Freight Unit Price]:&lt;BR /&gt;MAPPING LOAD&lt;BR /&gt; "Freight Number"&lt;BR /&gt;,"Amount" / "Freight Weight" as "Freight Unit Price"&lt;BR /&gt;RESIDENT [Freight Document]&lt;BR /&gt;;&lt;BR /&gt;DROP FIELD "Freight Weight"&lt;BR /&gt;;&lt;BR /&gt;LEFT JOIN ([Sales Order])&lt;BR /&gt;LOAD&lt;BR /&gt; "Order Number"&lt;BR /&gt;,"Weight" * applymap('Freight Unit Price',"Freight Number") as "Freight Amount"&lt;BR /&gt;RESIDENT [Sales Order]&lt;BR /&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2009 04:07:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145301#M24034</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2009-05-28T04:07:05Z</dc:date>
    </item>
    <item>
      <title>How can I do this calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145302#M24035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You Very Much, I learned a lot with the help that all of you gave me, and I've got the number I need in my script now!&lt;IMG alt="Big Smile" src="http://community.qlik.com/emoticons/emotion-2.gif" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2009 21:23:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-can-I-do-this-calculation/m-p/145302#M24035</guid>
      <dc:creator>rcandeo</dc:creator>
      <dc:date>2009-05-28T21:23:03Z</dc:date>
    </item>
  </channel>
</rss>

