Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
74Spain
Contributor
Contributor

Script with Conditionals and multiple conditions

Hi all, I'm struggling with the Script of my first Qlikview so any help Will be much appreciated!

-I have a Table with products and different measures and years (2010 and 2011)

-I need to create via Script a calculated field ([Type]) that basically does the following:

if year=2010 and Volume is positive AND year=2011 and Volume is positive then Type Will be OK

if year=2010 and Volume is Negative AND year=2011 and Volume is positive then Type Will be NEW

if year=2010 and Volume is positive AND year=2011 and Volume is Negative then Type Will be DELISTED

Thanks a lot before hand

3 Replies
chrismarlow
Specialist II
Specialist II

Hi,
Can you show screenshots of what you have so far? Do you have a field 'Year' or a date from which you want to get the year (assuming you are aggregating up somehow & 2010/2011 are not just columns, but maybe they are)?
What is the field you would aggregate/join over - product, is there are product ID, or just a name …?
Are you sure you need to do this in script? If you do then your Type won't update if you filter (there might be value in filtering by something other than product/date, region say), if you do as an expression in a chart it will.
Cheers,
Chris.
74Spain
Contributor
Contributor
Author

Hi Chris, I have just a table not much to show sorry. [Year] is a field. The key is Product code and we have different measures for them, one is Volume and this is the one I need to define this calculated field. 

This Type field is not changing, if one product has volume in 2010 and no volume in 2011 this mens is Delisted etc... This analysis is just for two years and we always use year end data, therefore [Type] does not change.

hope this is a bit more clear, otherwise I’ll try to attach more info.

thanks

74Spain
Contributor
Contributor
Author

example.jpg