Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

d_prashanthredd
Contributor III

How to calculate total quantity by City/Customer

Hi Experts,

I have one data set with products and their socket # and quantity.


Sample Data: File attached

In above example Total Sockets can be achieved by simple multiplication but my requirement is to calculate total sockets quantity by city and also by customer.

Note: We can't do sum(sockets) * sum(quantities) as Socket # is specific to product id and can be same for other orders and only quantities can be summed for the respective product. Calculation should be like.. mentioned below (socket#  * sum(qty))

Please help me in getting below outputs..?

Thanks,

Prashanth Reddy D.

1 Solution

Accepted Solutions

Re: How to calculate total quantity by City/Customer

Or just use this

=Sum(Sockets * Qty)


Capture.PNG

Qlik Sense sample and sample image attached

Capture.PNG

5 Replies

Re: How to calculate total quantity by City/Customer

This?

Capture.PNG

Re: How to calculate total quantity by City/Customer

Or just use this

=Sum(Sockets * Qty)


Capture.PNG

Qlik Sense sample and sample image attached

Capture.PNG

arvind1494
Valued Contributor

Re: How to calculate total quantity by City/Customer

Hi Prashant ,

Use the following script while loading this data:

Table:

LOAD City,

     Customer,

     OrderID,

     Product,

     Sockets,

     Qty,

     [Total Sockets (Sockets * Qty)]

FROM

(ooxml, embedded labels, table is Sheet1) Where RecNo() <11;

Table1:

LOAD City,sum(Sockets*Qty) as city_Sockets Resident Table Group by City;

Table2:

LOAD Customer,sum(Sockets*Qty) as Customer_Sockets Resident Table Group by Customer;

I attached screenshot of output: This is Original Data

data1.png

this is your required output:

data.png

d_prashanthredd
Contributor III

Re: How to calculate total quantity by City/Customer

Thanks Sunny,

Working as expected..

d_prashanthredd
Contributor III

Re: How to calculate total quantity by City/Customer

Thanks Arvind..

I can't do that in load script. I have to do that in front end. Anyways thanks for your prompt resp.

Community Browser