Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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.

Tags (3)
1 Solution

Accepted Solutions
anbu1984
Honored Contributor III

Re: divide with 2 collumms/tables in 1

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

3 Replies

Re: divide with 2 collumms/tables in 1

Hi

Try like this

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

anbu1984
Honored Contributor III

Re: divide with 2 collumms/tables in 1

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

MVP
MVP

Re: divide with 2 collumms/tables in 1

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...

Community Browser