Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Script If ApplyMap

Hi

In the QV script I have the below 2 functions that seem to work ok, but I'm actually trying to combine them so I can put a list feild on the page that will drill the charts accordingly.

ApplyMap ('ratm', [Rate Code] )as [Structured or Unstructured],

if(mid(Opics,6,2)<>'AL','Unstructured','Annuity') as Annuity,

What I would like it to say is , if the mid digits in 'OPICS' is AL call it Annuity, if its not go to map and apply accordingly , call this result [Structured/Unstructured]

I have tried many combinations but I think it should look something like this but its just not working

if(mid(Opics,6,2)<>'AL','Annuity',ApplyMap(ratm',[Rate Code])) as [ Structured or Unstructured],

Can anyone please help ?

Thanks Anne





















































5 Replies
vgutkovsky
Master II
Master II

Assuming you copied-and-pasted verbatim, I think it's just a syntax error. Try this instead:

if(mid(Opics,6,2)='AL','Annuity',ApplyMap('ratm',[Rate Code])) as [Structured/Unstructured]

If this doesn't work, then most likely you have a problem with your map. Please provide more details on what's failing exactly.

Regards,

Not applicable
Author

Hi Vlad,

This worked perfect , am I right to say my only issue with how I wrote is it by using <> rather than = ?

Thanks

Anne

vgutkovsky
Master II
Master II

Well no, not really, that was just a personal preference on my part. Your problem is that you were trying to make the output 2 fields instead of 1 (called [Structured or Unstructured] and Annuity). For your purposes this doesn't work.

Not applicable
Author

So it was the "OR" in the Structured Unstructured column ?

I should not use these and try / instead ?

Thanks

vgutkovsky
Master II
Master II

Anne,

You were trying to create a field called [Structured or Unstructured]. Then, in you IF statement, you were using the word "Unstructured" (having absolutely nothing to do with the field you created). It doesn't work that way. You can apply a map conditionally, it just has to be done within 1 declaration. Or with a preceding load. For example:


LOAD
if(myfield3='ABC','ABC',myfield2) as finaloutput
LOAD
applymap('mymap',myfield1) as myfield2
;


Regards,