Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
===>
USD & USD ......
When C2_SCURAB = 'USD' And C2_PCURAB = 'USD'
Eval Freight = C2_TPLCAB * C2_FCHPAB
Eval Duty = (C2_TPLCAB + Freight) * C2_DUTPAB
Eval Cost = C2_TPLCAB + Freight + Duty
Eval PMargin=((C2_SPLCAB-Cost)/C2_SPLCAB)*100
====>
JPY & JPY ......
When C2_SCURAB = 'JPY' And C2_PCURAB = 'JPY'
Eval Freight = C2_TPOCAB * C2_FCHPAB
Eval Duty = (C2_TPOCAB + Freight) * C2_DUTPAB
Eval Cost = C2_TPOCAB + Freight + Duty
Eval PMargin=((C2_SPOCAB-Cost)/C2_SPOCAB)*100
====>
USD & JPY ......
When C2_SCURAB = 'USD' And C2_PCURAB = 'JPY'
Eval SMJ1DS = RtvExchRate(C2_CUSTAB:
C2_MURAAB:
C2_REELAB:
C2_CNORAB)
Eval TP_Pro = C2_TPOCAB / ExchRate
Eval Freight = TP_Pro * C2_FCHPAB
Eval Duty = (TP_Pro + Freight) * C2_DUTPAB
Eval Cost = TP_Pro + Freight + Duty
Eval PMargin=((C2_SPLCAB-Cost)/C2_SPLCAB)*100
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. 🙂
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:)
Greetings,
Beata
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.
"artcode" identifies the type of item, right?
Frankly, your best option may be to left join the Margin table onto your Main table by artcode, and use this expression:
1 - sum(Kostprijs*esr_aantal)/sum(prijs83*esr_aantal)
QlikView's data compression should take care of the possible down sides. But sticking with a chart solution, I think this:
1 - sum(aggr(Kostprijs*sum(prijs83),artcode))/sum(prijs83*esr_aantal)
At least I hope that's right. It produces some numbers, anyway. Not sure if they're the right numbers.