Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

QlikView - how to apply different gross margin % to different plants

Hi

I am new to QlikView and would like to ask how to perform calculation as example below :

PlantMonthGross Margin %
ASep-1310%
AOct-1317%
ANov-1314%
ADec-1318%
BAug-1319%
BSep-1319%
BOct-1315%
BNov-1319%

PlantDateSales
A19/9/2013                   264.72
A20/9/2013                   590.48
A21/9/2013                   751.19
A13/8/2013                   607.21
B14/8/2013                   944.56
B15/8/2013                   335.48
B6/7/2013                   162.15
B1/6/2013                   892.66

So that gross margin can be computed :

PlantMonthGross Margin
ASep-13 283.71
BAug-13 238.58

Currently these data is residing in 2 different tables; and I tried to use set analysis & variable to do the operations similar to Excel array formula but was not successful. Please help.

8 Replies
spividori
Specialist
Specialist

Hi.

Could you explain how to calculate gross margin, eg A Sep-2013?, As do you know that the result is 283.71?

Regards.

Not applicable
Author

Hi Sandro,

Thanks for the reply!

Actually there is some error when I copy & paste the values from Excel as I was using random function.

So e.g. for plant A in Sep 2013 the gross margin should be (264.72 + 590.48 + 751.19) x 10% = 160.64

I used below formula to extract the gross margin % from database :

sum({<Year={$(=max(Year))},Month={$(=num(Month( now())))},Account={GPRatio} >} Figure)

whereas aggr(vSales, plant) as sales. vSales is a variable = sum({<Year={$(=max(Year))},Month={$(=num(Month( now())))} >} Sales)

so on plant level (when selection is done) is correct but group level is wrong as it 'sum' up all gross margin %.

Regards,

Eric

jagan
Luminary Alumni
Luminary Alumni

Hi,

Please find attached file for solution.

Regards,

Jagan.

Not applicable
Author

Hi Jagan,

Thanks for the reply!

Actually I am looking for value to be shown in a Textbox. I have modified your file. Pls. refer to attached.

I have a plant selector. If I don't select it (that means I want to see total) then the value inside blue Textbox is blank. If instead I choose either plant A or B then I can see each value.

Pls. help.

Regards,

Eric

Anonymous
Not applicable
Author

Try this:

T1:
LOAD * INLINE [
Plant, Month, GM,
A, Sep-13, 10%,
A, Aug-13, 10%,
A, Oct-13, 17%,
A, Nov-13, 17%,
A, Dec-13, 17%,
A, Jul-13, 17%,
A, Jun-13, 17%,
B, Aug-13, 17%,
B, Sep-13, 17%,
B, Oct-13, 17%,
B, Nov-13, 17%,
B, Jul-13, 17%,
B, Jun-13, 17%,
];

Map_T2:
MAPPING LOAD
Plant&'|'&Month as [Plant Month],
GM
Resident T1;

T2:

LOAD * INLINE [
Plant, Date, Sales,
A, 19/9/2013,264,
A, 20/9/2013,590 ,
A, 21/9/2013,751, 
A, 13/8/2013,607,
B, 14/8/2013,944,
B, 15/8/2013,335,
B, 6/7/2013,162,
B, 1/6/2013,892,
];

T3:
LOAD

     Plant,
     Date,
     Sales,
     Month(Date)&'-'&Date(Date,'YY') as MonthDate,
     ApplyMap('Map_T2', Plant&'|'&Month(Date)&'-'&Date(Date,'YY'), 'Not yet defined') as GM


Resident T2;

T4:
LOAD
Plant,
    MonthDate,
    GM,
    Sales,
    GM*Sales as [GM $]

Resident T3;

T5:
Load
Plant,
MonthDate,
Sum([GM $]) as [Total Margin]
Resident T4
Group By Plant, MonthDate;

DROP Table  T1, T2, T3, T4;

jagan
Luminary Alumni
Luminary Alumni

Hi,

Use this expression in Text object

 

=Sum(Aggr(Sum(Sales) * GrossMarginPer, Plant))

Regards,

Jagan.

spividori
Specialist
Specialist


HI.

In Text object try:

=Sum(Sales * GrossMarginPer)

Regards.

Not applicable
Author

Thanks eruditio, Jagan & Sandro! I will study your advices and revert later.