Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

divide with 2 collumms/tables in 1

Hi guys,

can you tell me how can I divide with 2 tables ?

example:

Tab1:

Load DocNo,

     ArtNo,

     Cost, // here are amounts that costs with discount like: 550€ & -50€

     Quantity, //here are all quantity like 25 and 25

FROM ..

Now I want to sum(cost)/sum(quantity).

Is it possible to use it in script?

Backend in expressions, it works.

1 Solution

Accepted Solutions
anbu1984
Master III
Master III

You have to use group by

Load DocNo,

     ArtNo,

     sum(cost)/sum(quantity)

FROM ..

Group by //Include all columns other than cost and quantity

DocNo,ArtNo

View solution in original post

3 Replies
MayilVahanan

Hi

Try like this

Load DocNo, ArtNo, Cost, Quantity, Cost/Quantity As Percentage From ... ;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
anbu1984
Master III
Master III

You have to use group by

Load DocNo,

     ArtNo,

     sum(cost)/sum(quantity)

FROM ..

Group by //Include all columns other than cost and quantity

DocNo,ArtNo

MK_QSL
MVP
MVP

You can do as below

1)

Tab1:

Load DocNo,

     ArtNo,

     Cost,

     Quantity,

     Cost/Quantity as YourNewFieldName

FROM ..

2)

Tab2:

Load

     DocNo,

     ArtNo,

     SUM(Cost)/SUM(Quantity) as YourNewFieldName

Resident Tab1

Group By DocNo, ArtNo...

But the 1st Method is more efficient...