Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
vanir88
Creator
Creator

How to use if condition in script to extract fields

Hi

Anyone please tell the script for below condition

Here [Results], [Country],[Email] are Exiting Columns

if [results]= blank and [Country] =blank then check [Email],  for @ google.com type "google not selected"   for rest "Country not selected" in [Country ] column

1.[results] and [Country]  is Blank

2. goto [email] column check if @Google.com then type  "google not selected" in [country] column

3. for rest of the [email] type  'Country not selected' in [country] column

 

Labels (1)
4 Replies
henrikalmen
Specialist
Specialist

I don't really understand what you want but this is the principle:

if(len([results])=0 and len([Country])=0,
   if(wildmatch[Email], '*@google.com'),
       'results is blank and country is blank and email is google',
       'results is blank and country is blank and email is NOT google'
    ),
'results and/or country is not blank, email can be anything'
)

You can read about if-statements here: https://help.qlik.com/en-US/sense/November2022/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptCont...

vanir88
Creator
Creator
Author

if [results]= blank and [Country] =blank then check [Email],  if it is  @ google.com type "google not selected"   in [Country] column.
for rest of the [Email] records type "Country not selected" in [Country ] column

this is requirement exmple. 

so first it will check Results & Country columns [Blank] then check [Email] column if it is @ google.com- then type  "google not selected" in Country Column, for rest of the [Email] type "Country not selected" in Country Column

ID Results Email Country
5   ads@google.com  
6   gdg@ms.com  
7   fdgt@google.com  

for this i need condition

henrikalmen
Specialist
Specialist

LOAD ...,
     if(len([results])=0 and len([Country])=0,
       if(wildmatch[Email], '*@google.com'),
         'Country not selected',
         'google not selected'
       ),
     [Country]
     ) as [Country],
     ...
FROM ...
;

It will give you that, and if results has a value and/or Country already has a value, the value of Country will remain (even if it is blank).

I wrote this in the form of a load script since you asked how to do it in script. But it's kind of the same thing to write it as a measure in a table chart.

vanir88
Creator
Creator
Author

Ok, Thank you i will try this