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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

sum set analysis

Can someone help me on this question?

I have a table contain quite a few fields like below. Lets say two of fields are A and B. I want to calcuate sum(A*B). The question is that I expect sum(A*B) equals to 10+2+18. but it is not.

table:

---------------------------

key, A, B, A*B...

1    , 2, 5, 10,...

2    , 1, 2, 2,...

3    , 6, 3, 18,...

---------------------------

if I select key field 1, the table become like below, just have the first row.

------------------------------

key, A, B, A*B...

1    , 2, 5, 10,...

------------------------------

I expected sum(A*B) = 10. But its calcuated result is (2+1+6)*5=45.

if I did sum(B)*A it will give me 5*2=10

I am confused. Under the current selection, A should just be number 2, why when I did sum(A*B), it sum all A value (2, 1, 6)?

Thanks,

9 Replies
Anonymous
Not applicable
Author

if you want to use corresponding rows for A and B to be multiplied for table, use order by key while loading Table.. other wise it will not know which A value to multiply with B and finally make sum.. and qvd can not support orderby only resident table

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I can't explain from the information you've given. Can you post a qvw that shows the problem?

-Rob

Not applicable
Author

I cant replicate this..

If I put the data into an INLINE table

Load * INLINE [

key,A,B

1,2,5

2,1,2

3,6,3

];

Then load the script and create a chart object straight table using Dimension as Key - no matter what I do - SUM(A*B) always give correct answer.

As Rob says - can you attached a qvw ?

ashwanin
Specialist
Specialist

Hi Chayong,

QV is reflecting the same, what you required in your output.

have a look in attached QV.

er_mohit
Master II
Master II

see the attached file

Not applicable
Author

Hi, everyone, thanks for helping, I think one thing I did not make it clear. It was that column B is 1-1 relationship with key, but A column is joined in table by another key value C. This may cause the problem. But still not sure how to solve

Not applicable
Author

Hi, Thanks a lot for helping. Here is the example of my question.

Not applicable
Author

I find one solution.

//Rate1:

//Load distinct

//System,RatePermm

//resident Brokerage;

Not applicable
Author

Hi, Here is the example of my problem and now I find one solution for it.

//Rate1:

//Load distinct

//System,RatePermm

//resident Brokerage;