Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
GraceGao
Creator
Creator

Get correct field value in Qlik sense

Hi Experts

as per below screenshot, there is sales table ,price system table and price manual maintain table.

in the load script, i left join 3 tables and calculate qty=sales/price,however the result is not my expected.

user want to retrieve material's price in the system first, and system has not this material's price then to lookup the maintain table's price. however, if one day, the system maintained material price in system, and user could not aware this, the material price exist in both price system table and manual maintain table, then the sales amount is double,the calculation is wrong. 

could you please advise, how can i do this logic in the script editor?

Thanks.

2 Solutions

Accepted Solutions
gmenoutis
Partner - Creator II
Partner - Creator II

If I understand correctly, if the material exists in both [Price Table] and [Price Temp Table], you want to only consider the [Price Table] values. You can do this with careful load order and a WHERE clause.

1) Load the [Price Table] *before* loading the sales table

[Price Table]: load ............ from ....(price table source)

2) Do a concatenate load from price temp table only for the materials who are not already present in price table:

concatenate load([Price Table]) .... from ....(price temp table source) where not exists([Material])

Now you only have one table, [Price Table], which has one price for each material.

3) Load sales table as usual

4) Join sales table and price table (there is no third table to join)

View solution in original post

GraceGao
Creator
Creator
Author

Hi gmenoutis

 

Thanks so much. it is working .

View solution in original post

2 Replies
gmenoutis
Partner - Creator II
Partner - Creator II

If I understand correctly, if the material exists in both [Price Table] and [Price Temp Table], you want to only consider the [Price Table] values. You can do this with careful load order and a WHERE clause.

1) Load the [Price Table] *before* loading the sales table

[Price Table]: load ............ from ....(price table source)

2) Do a concatenate load from price temp table only for the materials who are not already present in price table:

concatenate load([Price Table]) .... from ....(price temp table source) where not exists([Material])

Now you only have one table, [Price Table], which has one price for each material.

3) Load sales table as usual

4) Join sales table and price table (there is no third table to join)

GraceGao
Creator
Creator
Author

Hi gmenoutis

 

Thanks so much. it is working .