<?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 If statement in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152275#M29765</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your response John.&lt;/P&gt;&lt;P&gt;Basically, the code calculates profit margin on a unit level. I would like to create a chart/gauge to show total profit margin %. In order to this, I would need to sum up sales amount and cost amount, but both can vary based on Sales currency and purchase currency. Every field need for calculation is included in source file.including exchange rate, so no look up is necessary.&lt;/P&gt;&lt;P&gt;if sales currency and purchase currency = usd and usd, then logic 1 is used. jpy and jpy logic2 is used, and usd and jpy logic3 is used.&lt;/P&gt;&lt;P&gt;I guess to be more specific my question is how should using different price fileds based on currency.&lt;/P&gt;&lt;P&gt;Calculating cost = (tp price +freight + duty)&lt;/P&gt;&lt;P&gt;margin=salesprice-(tp price+freight +duty)/salesprice&lt;/P&gt;&lt;P&gt;Yes, I need assistance with load the when statements as if statments in Qlikview, or what is the best logic for QV script.&lt;/P&gt;&lt;P&gt;I need to load values based on local or orginal sales price and cost based on local or orignal tp price based on currency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Aug 2009 04:55:31 GMT</pubDate>
    <dc:creator>karensmith</dc:creator>
    <dc:date>2009-08-10T04:55:31Z</dc:date>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152273#M29763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to reproduce this type of logic in my script in order to calculate our summarized order margin amount. The below calculations are done on a unit price level. How can I reproduce this logic in my load script. The logic is based on a combination of sales currency and purchase currency. Can someone suggest how to do this?&lt;/P&gt;&lt;P dir="ltr"&gt;===&amp;gt;&lt;/P&gt;&lt;P dir="ltr"&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P dir="ltr"&gt;USD &amp;amp; USD ......&lt;/P&gt;&lt;P dir="ltr"&gt;When C2_SCURAB = 'USD' And C2_PCURAB = 'USD'&lt;/P&gt;&lt;P dir="ltr"&gt;Eval Freight = C2_TPLCAB * C2_FCHPAB&lt;/P&gt;&lt;P dir="ltr"&gt;Eval Duty = (C2_TPLCAB + Freight) * C2_DUTPAB&lt;/P&gt;&lt;P dir="ltr"&gt;Eval Cost = C2_TPLCAB + Freight + Duty&lt;/P&gt;&lt;P dir="ltr"&gt;Eval PMargin=((C2_SPLCAB-Cost)/C2_SPLCAB)*100&lt;/P&gt;&lt;P dir="ltr"&gt;====&amp;gt;&lt;/P&gt;&lt;P dir="ltr"&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P dir="ltr"&gt;JPY &amp;amp; JPY ......&lt;/P&gt;&lt;P dir="ltr"&gt;When C2_SCURAB = 'JPY' And C2_PCURAB = 'JPY'&lt;/P&gt;&lt;P dir="ltr"&gt;Eval Freight = C2_TPOCAB * C2_FCHPAB&lt;/P&gt;&lt;P dir="ltr"&gt;Eval Duty = (C2_TPOCAB + Freight) * C2_DUTPAB&lt;/P&gt;&lt;P dir="ltr"&gt;Eval Cost = C2_TPOCAB + Freight + Duty&lt;/P&gt;&lt;P dir="ltr"&gt;Eval PMargin=((C2_SPOCAB-Cost)/C2_SPOCAB)*100&lt;/P&gt;&lt;P dir="ltr"&gt;====&amp;gt;&lt;/P&gt;&lt;P dir="ltr"&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P dir="ltr"&gt;USD &amp;amp; JPY ......&lt;/P&gt;&lt;P dir="ltr"&gt;When C2_SCURAB = 'USD' And C2_PCURAB = 'JPY'&lt;/P&gt;&lt;P dir="ltr"&gt;Eval SMJ1DS = RtvExchRate(C2_CUSTAB:&lt;/P&gt;&lt;P dir="ltr"&gt;C2_MURAAB:&lt;/P&gt;&lt;P dir="ltr"&gt;C2_REELAB:&lt;/P&gt;&lt;P dir="ltr"&gt;C2_CNORAB)&lt;/P&gt;&lt;P dir="ltr"&gt;Eval TP_Pro = C2_TPOCAB / ExchRate&lt;/P&gt;&lt;P dir="ltr"&gt;Eval Freight = TP_Pro * C2_FCHPAB&lt;/P&gt;&lt;P dir="ltr"&gt;Eval Duty = (TP_Pro + Freight) * C2_DUTPAB&lt;/P&gt;&lt;P dir="ltr"&gt;Eval Cost = TP_Pro + Freight + Duty&lt;/P&gt;&lt;P dir="ltr"&gt;Eval PMargin=((C2_SPLCAB-Cost)/C2_SPLCAB)*100&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Aug 2009 02:06:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152273#M29763</guid>
      <dc:creator>karensmith</dc:creator>
      <dc:date>2009-08-08T02:06:19Z</dc:date>
    </item>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152274#M29764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This looks like a pretty open-ended problem. What specifically do you need help with?&lt;/P&gt;&lt;P&gt;Do you need help applying the WHEN logic? You could handle the WHENs as IFs within one load statement. You could handle the WHENs as WHENs and have multiple load statements concatenating data.&lt;/P&gt;&lt;P&gt;Do you need help looking up an exchange rate from a separate table? You appear to be calling a function of some sort, and don't provide the internals of the function, so I'm not sure I can help with that without more information.&lt;/P&gt;&lt;P&gt;Do you need help condensing this down? In QlikView, you can only refer to fields that have already been loaded. So if you want Duty to use Freight in its calculation, you either need to repeat the Freight expression, or use multiple loads, left joining each new field onto the existing data.&lt;/P&gt;&lt;P&gt;You might want to implement an exchange rate for each row, with a value of 1 when there's no currency difference. Then you could always divide by the Exchange rate at the end.&lt;/P&gt;&lt;P&gt;I wouldn't multiply your percentage by 100. QlikView can display 0.73 as 73% with no problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Aug 2009 03:02:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152274#M29764</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2009-08-08T03:02:35Z</dc:date>
    </item>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152275#M29765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your response John.&lt;/P&gt;&lt;P&gt;Basically, the code calculates profit margin on a unit level. I would like to create a chart/gauge to show total profit margin %. In order to this, I would need to sum up sales amount and cost amount, but both can vary based on Sales currency and purchase currency. Every field need for calculation is included in source file.including exchange rate, so no look up is necessary.&lt;/P&gt;&lt;P&gt;if sales currency and purchase currency = usd and usd, then logic 1 is used. jpy and jpy logic2 is used, and usd and jpy logic3 is used.&lt;/P&gt;&lt;P&gt;I guess to be more specific my question is how should using different price fileds based on currency.&lt;/P&gt;&lt;P&gt;Calculating cost = (tp price +freight + duty)&lt;/P&gt;&lt;P&gt;margin=salesprice-(tp price+freight +duty)/salesprice&lt;/P&gt;&lt;P&gt;Yes, I need assistance with load the when statements as if statments in Qlikview, or what is the best logic for QV script.&lt;/P&gt;&lt;P&gt;I need to load values based on local or orginal sales price and cost based on local or orignal tp price based on currency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2009 04:55:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152275#M29765</guid>
      <dc:creator>karensmith</dc:creator>
      <dc:date>2009-08-10T04:55:31Z</dc:date>
    </item>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152276#M29766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, unless I'm missing something, the logic across all three is basically identical except for the use of C2_TPLCAB vs. C2_TPOCAB, at least if your exchange rate for equal currencies is loaded as 1. But we can handle it even if it isn't. If load speed isn't a problem, here's a multi-pass approach that keeps the calculations simple:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;[Data]:&lt;BR /&gt;LOAD&lt;BR /&gt; recno() as ID&lt;BR /&gt;,if(C2_SCURAB='USD' and C2_PCURAB='USD',C2_TPLCAB,C2_TPOCAB) as C2_TPxCAB&lt;BR /&gt;,if(C2_SCURAB=C2_TPLCAB,1,ExchRate) as ExchRate&lt;BR /&gt;,C2_FCHPAB&lt;BR /&gt;,C2_DUTPAB&lt;BR /&gt;,C2_SPLCAB as SalesPrice&lt;BR /&gt;...&lt;BR /&gt;;&lt;BR /&gt;LEFT JOIN LOAD ID, C2_TPxCAB / ExchRate as TPPrice RESIDENT ([Data]); DROP FIELD C2_TPxCAB;&lt;BR /&gt;LEFT JOIN LOAD ID, TPPrice * C2_FCHPAB as Freight RESIDENT ([Data]); DROP FIELD C2_FCHPAB;&lt;BR /&gt;LEFT JOIN LOAD ID, (TPPrice + Freight) * C2_DUTPAB as Duty RESIDENT ([Data]); DROP FIELD C2_DUTPAB;&lt;BR /&gt;LEFT JOIN LOAD ID, TPPrice + Freight + Duty as Cost RESIDENT ([Data]); DROP FIELD ID;&lt;/P&gt;&lt;P&gt;Profit margin can't be calculated in the load because you have to sum, THEN divide, and display as percent to avoid multiplying by 100. So that become a chart expression like this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;1 - Cost / SalesPrice&lt;/P&gt;&lt;P&gt;If load speed IS a problem, you probably won't want to make multiple passes. You may want to compare the speed of a single pass approach. Since QlikView won't recognize calculated fields until the load is complete, it's an algeabra problem to expand all of the expressions back to the original variables. Assuming I did my algeabra right, something like this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LOAD&lt;BR /&gt; if(C2_SCURAB='USD' and C2_PCURAB='USD',C2_TPLCAB,C2_TPOCAB)&lt;BR /&gt;/if(C2_SCURAB=C2_TPLCAB,1,ExchRate) as TPPrice&lt;BR /&gt;,if(C2_SCURAB='USD' and C2_PCURAB='USD',C2_TPLCAB,C2_TPOCAB) * C2_FCHPAB&lt;BR /&gt;/if(C2_SCURAB=C2_TPLCAB,1,ExchRate) as Freight&lt;BR /&gt;,if(C2_SCURAB='USD' and C2_PCURAB='USD',C2_TPLCAB,C2_TPOCAB) * (1 + C2_FCHPAB) * C2_DUTPAB&lt;BR /&gt;/if(C2_SCURAB=C2_TPLCAB,1,ExchRate) as Duty&lt;BR /&gt;,if(C2_SCURAB='USD' and C2_PCURAB='USD',C2_TPLCAB,C2_TPOCAB) * (1 + C2_FCHPAB) * (1 + C2_DUTPAB)&lt;BR /&gt;/if(C2_SCURAB=C2_TPLCAB,1,ExchRate) as Cost&lt;BR /&gt;,C2_SPLCAB as SalesPrice&lt;BR /&gt;...&lt;BR /&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2009 01:07:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152276#M29766</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2009-08-11T01:07:30Z</dc:date>
    </item>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152277#M29767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking for some help, and I think you are the best person to ask. I have kind of similar problem. I am trying to do full margin analysis, with a possibility to see margin to each product, product group, customer and customer group. In my script it looks like that:&lt;/P&gt;&lt;P&gt;/*****Main****/&lt;BR /&gt;Main:&lt;BR /&gt;LOAD ID,&lt;BR /&gt; faknr,&lt;BR /&gt; fakdat as CalendarDate,&lt;BR /&gt; artcode,&lt;BR /&gt; if(left(oms45,10)='LOEMPIAVEL','99',if(left(artcode,5)='14020','98',left(artcode,2))) as ProductgroepNummer,&lt;BR /&gt; oms45 as ProductDescription,&lt;BR /&gt; afl_week,&lt;BR /&gt; esr_aantal, -----&amp;gt; number of items&lt;BR /&gt; korting,&lt;BR /&gt; prijs_n,&lt;BR /&gt; &lt;B&gt;prijs83&lt;/B&gt;,&lt;BR /&gt; vvp,&lt;BR /&gt; pr_bedr,&lt;BR /&gt; ordernr,&lt;BR /&gt; verzdebnr as Klantnummer,&lt;BR /&gt; bdr_ev_ed_val as InvoiceAmount,&lt;BR /&gt; bdr_d_ev_val,&lt;BR /&gt; bdr_inv_d_val&lt;BR /&gt;FROM&lt;BR /&gt;[Amboina data needed.xlsx]&lt;BR /&gt;(ooxml, embedded labels, table is Sheet1);&lt;BR /&gt;&lt;BR /&gt;/*****Customer****/&lt;BR /&gt;Customer:&lt;BR /&gt;LOAD Klantnummer,&lt;BR /&gt; Klantnaam,&lt;BR /&gt; [New client group] as KlantGroep&lt;BR /&gt;FROM&lt;BR /&gt;[Customer list final, vs HJ.xls]&lt;BR /&gt;(biff, embedded labels, table is Blad1$);&lt;BR /&gt;&lt;BR /&gt;/*****Product****/&lt;BR /&gt;Product:&lt;BR /&gt;LOAD ProductgroepNummer,&lt;BR /&gt; Productgroep&lt;BR /&gt;FROM&lt;BR /&gt;[091215 Amboina Productgroepen.xlsx]&lt;BR /&gt;(ooxml, embedded labels, table is Sheet1);&lt;BR /&gt;Margin122008:&lt;BR /&gt;LOAD Artikel as artcode,&lt;BR /&gt; Artikelomschrijving,&lt;BR /&gt; Artikelgroep,&lt;BR /&gt; Omschrijving,&lt;BR /&gt; Status,&lt;BR /&gt; Eenheid,&lt;BR /&gt; &lt;B&gt;Kostprijs&lt;/B&gt;,&lt;BR /&gt;FROM&lt;BR /&gt;[090603 Voorraad per 31_12_2008, final version HJ.xlsx]&lt;BR /&gt;(ooxml, embedded labels, table is Blad1);&lt;/P&gt;&lt;P&gt;By usage of expression in chart i got margin for each product (I used average price of each item = 1- Kostprijs/ avg(prijs83), what is also kind of incorrect, as we sell to customers with different prices, so if I understand mathematics correctly, the result is not the same). But I have no idea how I could check the margin for each customer etc.&lt;/P&gt;&lt;P&gt;I would really appreciate your help!&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;Beata&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 17:18:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152277#M29767</guid>
      <dc:creator />
      <dc:date>2010-02-10T17:18:00Z</dc:date>
    </item>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152278#M29768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, let me see if I understand.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;"Main" is a table of invoices from you to your customers.&lt;/LI&gt;&lt;LI&gt;"esr_aantal" is the number of items on a particular invoice.&lt;/LI&gt;&lt;LI&gt;"prijs83" is the price for a single item. Different customers may pay a different price.&lt;/LI&gt;&lt;LI&gt;"Kostprijs" is the cost of the item. An item has the same cost, regardless of customer.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So your profit margin for ONE item is (prijs83 - Kostprijs)/prijs83, or more simply, 1 - Kostprijs/prijs83.&lt;/P&gt;&lt;P&gt;Your current calculation for ALL items is:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;1 - Kostprijs/avg(prijs83)&lt;BR /&gt;= 1 - Kostprijs/(sum(prijs83)/numberofinvoices)&lt;BR /&gt;= 1 - Kostprijs*numberofinvoices/sum(prijs83)&lt;/P&gt;&lt;P&gt;That's close, but we actually need to use the number of ITEMS, not the number of invoices. The number of items on an invoice is specified by field esr_aantal. So you want a weighted average price by esr_aantal. That would be sum(prijs83*esr_aantal)/sum(esr_aantal). Plugging THAT in:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;1 - Kostprijs/(sum(prijs83*esr_aantal)/sum(esr_aantal))&lt;BR /&gt;= 1 - Kostprijs*sum(esr_aantal)/sum(prijs83*esr_aantal)&lt;/P&gt;&lt;P&gt;Another way to have come at this is to recognize that we want the TOTAL cost, which would be Kostprijs*sum(esr_aantal). And that we want the TOTAL price, which would be sum(prijs83*esr_aantal). Both ways of thinking end up with the same expression, of course. So repeating myself, and assuming I understood your question, the answer is:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;&lt;STRONG&gt;1 - Kostprijs*sum(esr_aantal)/sum(prijs83*esr_aantal)&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 19:16:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152278#M29768</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-02-10T19:16:08Z</dc:date>
    </item>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152279#M29769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly thank you very much for spending time on that! definitely you understood the case correctly. So right now thanks to final formula I found out more proper item margin. Unfortunately still the case how to find out customer margin or product group margin is mission impossible for me. So, putting customer name as dimension and &lt;STRONG&gt;1 - Kostprijs*sum(esr_aantal)/sum(prijs83*esr_aantal)as an&lt;/STRONG&gt; expression in a chart doesn't work:( It's my first margin analysis in my whole life, so I am really appreciating your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;greetings from The Netherlands,&lt;/P&gt;&lt;P&gt;Beata&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 20:51:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152279#M29769</guid>
      <dc:creator />
      <dc:date>2010-02-10T20:51:17Z</dc:date>
    </item>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152280#M29770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd have expected the expression to work fine when breaking down by customer. It should limit the number of rows from the Main table, and therefore restrict sum(esr_aantal) and sum(prijs83*esr_aantal) to just the matching rows, and therefore give you a margin for just that customer. So I'm not sure what's going wrong. What are you seeing? Some wrong answer? A null answer? Maybe post a quick example with inline loads demonstrating the problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 21:03:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152280#M29770</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-02-10T21:03:30Z</dc:date>
    </item>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152281#M29771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hoped also it would work:-) If I use Customer Group as dimension there is no data displayed. When I use Customer as a dimension I have a result of 1 for three chosen customers (I didnt get it yet how QV restricted that)&amp;gt; Right now I am trying to upload the file, but without success, is the size restricted?&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;Beata&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 21:52:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152281#M29771</guid>
      <dc:creator />
      <dc:date>2010-02-10T21:52:24Z</dc:date>
    </item>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152282#M29772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok, I uploaded it into my files! Please let me know if you see it:)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;Beata&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 21:54:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152282#M29772</guid>
      <dc:creator />
      <dc:date>2010-02-10T21:54:51Z</dc:date>
    </item>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152283#M29773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm fairly sure the size is restricted, plus sometimes it simply doesn't work. I'd make the simplest possible sample file using inline data that still demonstrates the problem. If you find you can't make a sample file that demonstrates the problem, then you already have it solved, and just need to figure out how to apply it. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 21:56:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152283#M29773</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-02-10T21:56:09Z</dc:date>
    </item>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152284#M29774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes, it seems it doesn't work (I mean to post it here). Anyway it's uploaded in my profile files, and if you would be so kind, please take a look there! If I would solve this margin analysis, I suppose my boss would love me:) and you too:)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;Beata&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 22:09:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152284#M29774</guid>
      <dc:creator />
      <dc:date>2010-02-10T22:09:24Z</dc:date>
    </item>
    <item>
      <title>If statement</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement/m-p/152285#M29775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, OK, I see the problem. My mistake. We can't just use Kostprijs that way. Using it that way assumes that everything in the whole data set costs the same amount, which isn't the case. So we need to aggregate costs, not just multiply one cost by the total number of items.&lt;/P&gt;&lt;P&gt;"artcode" identifies the type of item, right?&lt;/P&gt;&lt;P&gt;Frankly, your best option may be to left join the Margin table onto your Main table by artcode, and use this expression:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;1 - sum(Kostprijs*esr_aantal)/sum(prijs83*esr_aantal)&lt;/P&gt;&lt;P&gt;QlikView's data compression should take care of the possible down sides. But sticking with a chart solution, I think this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;1 - sum(aggr(Kostprijs*sum(prijs83),artcode))/sum(prijs83*esr_aantal)&lt;/P&gt;&lt;P&gt;At least I hope that's right. It produces some numbers, anyway. Not sure if they're the right numbers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 22:25:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement/m-p/152285#M29775</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-02-10T22:25:52Z</dc:date>
    </item>
  </channel>
</rss>

