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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

IF statement in Script

I am currently doing the following as a Dimension in a chart, how Do I get this into a script?

Transactions is one table, ABICode is another table

=if(Transactions.ProductID = '33', Num(ABICode.ABIVixaInsuranceGroup),

if(Transactions.ProductID = '31', Num(ABICode.ABIBikeInsuranceGroup),Num(ABICode.ABIAxaInsuranceGroup)))

So in the script I would want to say something like - but i'm not sure where to put into the script.

if(Transactions.ProductID = '33', Num(ABICode.ABIVixaInsuranceGroup),

if(Transactions.ProductID = '31', Num(ABICode.ABIBikeInsuranceGroup),Num(ABICode.ABIAxaInsuranceGroup))) AS NewAbiInsurance Group

Labels (1)
13 Replies
Anonymous
Not applicable
Author

Mabye a typo?

Do you have a field named [Transactions.ProductID] and is your table namend [ABICode] ?

Not applicable
Author

I have a Field named ProductID in Transactions Table

I have a three fields in ABICode Table ABIVixaInsuranceGroup, ABIAxaInsuranceGroup, ABIBikeInsuranceGroup

If ProductID is 33 I need to look at Vixa column, if it's 31 I need to look at Bike, otherwise I want to look at Axa

This works fine in the chart I am using but if I want to then click on an insurance group in my chart it doesn't allow it because I am passing an if statement,

So to combat this I want to add an additional column in the transactions table - that could be called anything (ABAInsGroup) so that I can use this column in my chart.

Not sure if I am making sense (apologies and thanks for your help).

Anonymous
Not applicable
Author

Can you provide us with an example of your QV-document or at least the script you are using?

Not applicable
Author

let's try something else:

M_Vixa:

Mapping Load 1, ABIVixaInsuranceGroup Resident ABICode;

M_Bike:

Mapping Load 1, ABIBikeInsuranceGroup Resident ABICode;

M_Axa:

Mapping Load 1, ABIAxaInsuranceGroup Resident ABICode;

Data:

Load ProductID,

     if(ProductID = '33', ApplyMap('M_Vixa',1),

         if(ProductID = '31', ApplyMap('M_Bike',1),

             ApplyMap('M_Axa',1)

          )) as NewABIInsuranceGroup

Resident Transactions;