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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum of dimensions (aggr) in pivot table

Hi guys,

Question concerning the aggregation function.

I have 5 dimensions and 2 expressions.

Dimensions

*name customer

*article

*pieces per pack

*length

*width

Expression:

sum(NumberSold)

I need the to calculate:

pieces per pack * length * width * sum(NumberSold)

Knipsel.JPG

It is a pivot table, so I need the sum for each customer, but this is what qlikview does not want to show.

I am currently using the following expression for the last column:

=aggr

(

((max(length)*max(width))/1000)*max(pcsperpack), Klantnaam

)

But I am using this as an expression, and last time I was using it as a calculated dimension. I am a bit lost at the minute.. As you can see, the sum(NumberSold) is not even yet in the expression because I do not now where to put it..

Do I need a calculated dimension?

And which expression do I need for the last column?

Thanks a lot!!

Zipke

13 Replies
Not applicable
Author

The distinct solved the zero problem but it now makes a calculation that's not correct:

with the old expression:

=(sum(aggr(sum([Pcsperpack]*LENGTH*WIDTH/10000)*(NumberSold),Customer, Article)))/2

zonderdist.JPG

Now with distinct added to the expression I get these values:

=(sum(DISTINCT aggr(sum([Pcsperpack]*LENGTH*WIDTH/10000)*(NumberSold),Customer, Article)))/2

metdistinct.JPG

...

Not applicable
Author

A*B/10000 is the same as (A*B)/10000 ? So that does not change anything.

It is correct in a mathematical way, it just gives me something wrong for some of the values..

Alle the values used in the calculation are shown in the cart.

And I have to divide it by 2 or it gives me a wrong aswer..

Check the others:

Knipsel.JPG

60*125/10000*10*2=15, which is correct.

If I do not divide by 2, it shows me 30, view below:

Knipsel2.JPG

I do not know why it does it, but dividing it by 2 solves it anyway..

Not applicable
Author

The expression you have given me gives me '-' everywhere..

But...

I have got it, I have got it!

For some reason it works.

This was what I originally started with and it did not give me the total for some customers

=LENGTH*WIDTH/10000*Pcsperpack*sum(NumberSold)

Knipsel.JPG

And I changed it to this:

=sum(Pcsperpack*WIDTH*LENGTH/10000*NumberSold)

And this works!!

Knipsel2.JPG

Since it did not give me the sum for some of the customers, I thought I had to use aggr function, but apparently that's not even needed.. Good times!!

Thanks for all your effort and time though er.mohit!

Much appreciated!

Zipke

er_mohit
Master II
Master II

thumsup

So,Please Closed this thread to mark it as either helpful or correct answer so that it might be helpful for others developer

Regards

Mohit