Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a Qlikview script as below:
Load PrimaryIndicator,
SecondaryIndicator,
If(PrimaryIndicator = 'A' or
PrimaryIndicator = 'B' or
SecondaryIndicator = 'C' or
SecondaryIndicator = 'D', 'Dep','NonDep') as DepressionIndicator
Resident Table1;
How do i convert the if condition into a Apply Map and Mapping load combination ?
I'm able to convert an if condition with single column into Apply Map and Mapping load combination but this scenario involved 2 columns (PrimaryIndicator, SecondaryIndicator) and i'm unable to do it with 2 column involved.
Looking forward for some suggestions. Thanks in Advance!
Vignesh
May be
Map_Primary_Ind:
Mapping Load
Primary_Indicator,
'Dep' as Value
;
//Use your source table instead of below Inline
Load * Inline [
Primary_Indicator
A
B
];
Map_Secondary_Ind:
Mapping Load
Secondary_Indicator,
'Dep' as Value
;
Load * Inline [
Secondary_Indicator
C
D
];
In the table
Applymap('Map_Primary_Ind',Primary_Indicator,Applymap('Map_Secondary_Ind',Secondary_Indicator,'Non Dep')) as DepressionIndicator
You can create a mapping table where the first column is the concatenation of Primary and Secondary, and the second column is the Indicator.
Then, in the load, you can use:
applymap('mapping table name', PrimaryIndicator & SecondaryIndicator) as DepressionIndicator
May be
Map_Primary_Ind:
Mapping Load
Primary_Indicator,
'Dep' as Value
;
//Use your source table instead of below Inline
Load * Inline [
Primary_Indicator
A
B
];
Map_Secondary_Ind:
Mapping Load
Secondary_Indicator,
'Dep' as Value
;
Load * Inline [
Secondary_Indicator
C
D
];
In the table
Applymap('Map_Primary_Ind',Primary_Indicator,Applymap('Map_Secondary_Ind',Secondary_Indicator,'Non Dep')) as DepressionIndicator
You have two decent responses to your query, we would appreciate it if you would return to your thread and close it out by using the Accept as Solution button the post(s) that helped. If you did something different, you can post what you did and then mark that post too, and if you still require assistance, please leave an update post for us.
Regards,
Brett