Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Modiz
Contributor III
Contributor III

summing values ​​in a column with a condition based on two different tables

Hi,

I have two tables:

table1:

date_1            product            quantity

10.02                a                      10

11.02                a                       5

12.02                a                       3

10.02                b                       1

11.02                b                       2

 

table 2:

product   STORE  date_2    price    range_from     range_to

a               S1          11.02            5              1                  10

a               S1         11.02            6              11                 100

a              S1          11.02             7             1 01      

b             S1           10.02             3             1                  100

b              S1          10.02            5              101          

a             S2           12.02           5              1                  10

a             S2           12.02           6              11                 100

a             S2           12.02           7              1 01      

b            S2            11.02          3              1                     100

b           S2            11.02           5              101         

In table in QS i want to sum(quantity) but i need condition if date_1 >=date_2 . 

Ultimately I would like to have a table:

Table 3:

product    store      sum(quantity if date_1 >=date_2)

a                   S1        8

a                  S2         3

b                 S1         3

b                S2          2

 

 

Does anyone know how to write a condition in set expression?

It does not work:

aggr(nodistinct sum( {<store=, product=>} if(data_1>=date_2, quantity,0)),store,product)

Labels (2)
2 Replies
edwin
Master II
Master II

you are actualyy getting a cartesian just bec you are not linking your two tables.  change the column name of Product in table 2 to type and try it again.  without any explanation and just looking at your data, this assumes that type and product are the same.

fnaf12
Contributor
Contributor

In the brand-new horror game poppy playtime, you'll be alone in a huge toy factory while a scary beast chases you. Will you be ready for this trip? Start right away and have fun!