Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Saro_2306
Contributor II
Contributor II

If Statement

Hi Friends,

I have a query in writing if statement.  I have list of country names and need to group them with certain criteria and countries those which not satisfies criteria should me mentioned as 'Others'. Any one can please advise how to write script for this.?

 

if(Country=Kuwait' or Country='Abu Dhabi' or Country='Qatar' or Country='Bahrain' or Country='Iraq' or Country='Dubai ' , 'Gulf Countries', if(Country='Jordan' orCountry='Saudi Arabia' , 'Middle East Countries', ______) as Region

Labels (2)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

If you have a lot of values then it could be a better approach to use a mapping table and ApplyMap() to solve your need. Take a look at the script below.

mapRegion:
LOAD * inline [
A,         B
Kuwait,    Gulf Countries
Abu Dhabi,    Gulf Countries
Qatar,        Gulf Countries
Bahrain,      Gulf Countries
Iraq,         Gulf Countries
Jordan,       Middle East Countries
Saudi Arabia, Middle East Countries
Norway,       Scandinavian Countries
Sweden,       Scandinavian Countries
];

LOAD *,
applymap('mapRegion', Country, 'No region') as Region
FROM SOURCE;

View solution in original post

1 Reply
Vegar
MVP
MVP

If you have a lot of values then it could be a better approach to use a mapping table and ApplyMap() to solve your need. Take a look at the script below.

mapRegion:
LOAD * inline [
A,         B
Kuwait,    Gulf Countries
Abu Dhabi,    Gulf Countries
Qatar,        Gulf Countries
Bahrain,      Gulf Countries
Iraq,         Gulf Countries
Jordan,       Middle East Countries
Saudi Arabia, Middle East Countries
Norway,       Scandinavian Countries
Sweden,       Scandinavian Countries
];

LOAD *,
applymap('mapRegion', Country, 'No region') as Region
FROM SOURCE;