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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
JACKNIEKERK
Creator
Creator

Script to find total price by either Grams or Pieces in a database

 

have 2 tabels

the key is same Key:
(Itemnumber) in the 2 tabels

1 tabel has based on key 1 wich tells me product is either K (ilo) of U(nits) format

other tabel has same key, so based on that key should be possible
to see eiher K or U type product

then in same tabel the Qty value:
if K-type in field Grams
or if U-type value in field Pieces

then cost per K or U is always the same in field Price

so need some way by to get sum off
if K-type ( Grams x cost)
or if U-type ( Pieces x cost)

How to set this script In qlikview?

if vba I would set

If UnitType = "K" then 'in table 1)
Total = Grams * Cost
else
Total = Pieces * Cost
end if

 

1 Solution

Accepted Solutions
Kushal_Chawda

You can use below expression in UI. Same you can use it in script but for that you need to join the table and use below on resident load. If all columns are in same table then you can directly use below in that table load.

Pick(match(UnitType,'K','U'), Grams * Cost, Pieces * Cost) 

View solution in original post

2 Replies
Kushal_Chawda

You can use below expression in UI. Same you can use it in script but for that you need to join the table and use below on resident load. If all columns are in same table then you can directly use below in that table load.

Pick(match(UnitType,'K','U'), Grams * Cost, Pieces * Cost) 

JACKNIEKERK
Creator
Creator
Author

great!  thanks. this sample i can use in lots of other situations