Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

sum field after count distinct

Hello Qlikers!

Need help what  formula do I need for me to get the correct QTY  field.


correct QTY is derived by dividing QTY over # of LOTS per LOT TITLE.


I have done  sum(QTY) / # of LOTS but the result is 10639

or sum(QTY) / count(DISTINCT LOTS) = 23222.6


What I am after is the total of the correct QTY which is 168,649

    

LOTS# of LOTS        QTY     correct QTY
LOT 12       26,098            13,049
LOT 22        2,890              1,445
LOT 32       35,486            17,743
LOT 42       37,396            18,698
LOT 52       25,284            12,642
LOT 61       27,834            27,834
LOT 71       12,658            12,658
LOT 81       27,810            27,810
LOT 91       28,940            28,940
LOT 101        7,830              7,830
TOTAL15     232,226          168,649

thanks and hope I have explained my problem in detail.

1 Solution

Accepted Solutions
its_anandrjs
Champion III
Champion III

You have to use DiSTINCT or you have duplicate values for the single lots is this your data is correct

In Expression use

=Sum(Aggr(QTY,LOTS))

See my attached also

View solution in original post

10 Replies
its_anandrjs
Champion III
Champion III

Data that you provided it is latest and correct or it form the chart you provided?

Anonymous
Not applicable
Author

sorry I did not get your question but let me try to explain.

the data is a sample of the pivot chart except for the correct QTY field.

so LOTS, # of LOTS & QTY are part of pivot table, correct QTY field is a manual computation.

thanks

its_anandrjs
Champion III
Champion III

Ok i have to ask how you calculate  # of LOTS & QTY and you have difficulty in calculate the QTY or may be provide and sample for this.

Anonymous
Not applicable
Author

HI! I have attached a sample file.

its_anandrjs
Champion III
Champion III

You have to use DiSTINCT or you have duplicate values for the single lots is this your data is correct

In Expression use

=Sum(Aggr(QTY,LOTS))

See my attached also

Anonymous
Not applicable
Author

HI Anand, thank you! this is the expression I need.

its_anandrjs
Champion III
Champion III

You can use this also but carefully you have to do this.

=Sum( DISTINCT QTY )

Anonymous
Not applicable
Author

have tried it but =Sum(Aggr(QTY,LOTS)) is much closer


thanks!

Anonymous
Not applicable
Author

Hi Anand,

I would like to make  a follow up question on the formula.

Where can I insert the week in order for the data to reflect the current week only.

below formula is giving me a zero data

Sum({<Fiscal_Week = {"$(=MaxString(Fiscal_Week))"}>}Aggr(QTY,LOTS))

thanks