Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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;
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;