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

Add a column based on the conditions of the existing column.

TeamGroupNameDOBCountry and ClubContinent
AustraliaCDaniel Arzani1999-01-04Australia Melbourne CityAsia
FranceCKylian Mbappé1998-12-20France Paris Saint-GermainEurope
MoroccoBAchraf Hakimi1998-11-04Spain Real MadridAfrica
NigeriaDFrancis Uzoho1998-10-28Spain Deportivo FabrilAfrica
EnglandGTrent Alexander-Arnold1998-10-07England LiverpoolEurope
SenegalHMoussa Wagué1998-10-04Belgium EupenAfrica

 

Hi Qlik Sense experts, 

How are you today? I would like to add an additional column named 'Continent'

if Team ='France' or Team = 'England' then Contenent = 'Europe'

if else Team ='Morocco' or Team = 'Senegal then Contenent = 'Africa'

if else Team ='Australia' then Contenent = 'Asia' 

End if as Continent

How can I write a similar Qlik scripts to populate additional column as the above syntax?

 

Many Thanks and kind regards, 

 

Feng

 

Labels (3)
5 Replies
Vegar
MVP
MVP

One way of solving this is using Pick(Match()) like I've done below.

Pick( Match([Team],'Australia', 'France', 'Morocco','Nigeria','England','Senegal'),
                   'Asia',      'Europe', 'Africa', 'Africa,  'Europe', 'Africa') as Continent

]

lark9820
Contributor II
Contributor II
Author

Hi Regar,

 

Thanks for your kind help and prompt response, the point is that there are 32 soccer teams in the world cup, and around few thousands  of  soccer players, we can not use match() to manually fill in the Nations and continents for each player.

I am wondering if there is any chance to get a extra column to flag its continent.

Many Thanks

Regards,

Feng Gao

anushree1
Specialist II
Specialist II

Please try using Mapping load as below, in this case all you need to do is have an excel updated with all Countries and Continents, the rest will work seamlessly

Map_Continent:
Mapping Load * Inline
[Country,Continent
France,Europe
England,Europe
Morocco,Africa
Senegal,Africa
Australia,Asia
Spain,Africa
Belgium,Africa
];
Data:
Load *,
SubField([Country and Club],' ',1) as Test,
applymap('Map_Continent',SubField([Country and Club],' ',1) ,'NA') as Cont_Test;
load * Inline [
Team,Group, Name,DOB,Country and Club,
Australia,C, Daniel Arzani, 1999-01-04, Australia Melbourne City
France, C, Kylian Mbappé, 1998-12-20, France Paris Saint-Germain
Morocco, B, Achraf Hakimi, 1998-11-04, Spain Real Madrid
Nigeria, D, Francis Uzoho, 1998-10-28, Spain Deportivo Fabril
England, G, Trent Alexander-Arnold, 1998-10-07, England Liverpool
Senegal, H, Moussa Wagué, 1998-10-04, Belgium Eupen
];

Vegar
MVP
MVP

I'm not listing the Continent for each player in my example, I'm listing for each country.  (I've updated my previous answer with color coding and intendation to make my approach more readable).

The pick match is an quite quick approach when you have a few dimensions to match, but if you are planning for mapping all countries to a continent then I suggest you go with @anushree1  approach using ApplyMap

 

Brett_Bleess
Former Employee
Former Employee

Did any of the posts get you what you needed?  If so, do not forget to return to the thread and close things out by going to the post that helped and using the Accept as Solution Button to mark, which also gives the poster credit for the help and lets other Members know what worked.  If you are still working on things, please leave an update.  I do believe we did a Demo app on World Cup as well, which you should be able to find at https://demo.qlik.com/qlikview.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.