Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
niha
Creator II
Creator II

If else statement in scripting

Hello,

I have a Dimension Country . I want to create two Flag says Bigcountry and Small Country .  I have around 30 country and I want to have some work on specific country . Italy,France,Spain, United Kingdom as grouped as Big country and say A, B, C, d, E  grouped as small country. I want to develop it in scripts.  I tried below script.

If(Match('Country','Italy','France','Spain','United Kingdom'),'BigCountry''Country') as BigCountry,

If(Match('A','B','C,'d','e'),' small Country''Country') as SmallCountry,

But it is giving error. Please suggest.

Regards,

Niha

 

7 Replies
Stoyan_Terziev
Partner - Creator III
Partner - Creator III

Hi Niha,

 

You probably want to achieve this:

 

If(WildMatch(Country,'Italy','France','Spain','United Kingdom'),'BigCountry', If(WildMatch(Country,'A','B','C,'d','e'),' small Country', 'Not Specified')) as CountrySize

 

Anil_Babu_Samineni

Perhaps you missed comma (,

If(Match('Country','Italy','France','Spain','United Kingdom'),'BigCountry', 'Country') as BigCountry,

If(Match('A','B','C,'d','e'),' small Country', 'Country') as SmallCountry,

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
niha
Creator II
Creator II
Author

Hello,

Thanks a lot !  after trying this code I got this. looks like some error in scripting.  this is the code.

LOAD
Country,
If(Match('Country','Italy','France','Spain','United Kingdom'),'BigCountry', 'Country') as BigCountry,
If(Match('Egypt', 'Jordan', 'Lebanon' , 'Israel', 'Kuwait', 'Qatar'),'SmallCountry','Country') as SmallCountry,
"Full Name",
Position,
Area,

 Untitled.png

niha
Creator II
Creator II
Author

Hello,

Thanks. I want to group two separate groups from country. Say Country  column has 32 country. I want to create two group say Big Country which has country Italy, France, UK. Another group which has say Israel, Arab, Jordan so on. 

Regard,

NihaUntitled.png

Anil_Babu_Samineni

My bad, This should be this?

LOAD
Country,
If(Match(Country,'Italy','France','Spain','United Kingdom'),'BigCountry', 'Country') as BigCountry, // Country is field name
If(Match(Country, 'Egypt', 'Jordan', 'Lebanon' , 'Israel', 'Kuwait', 'Qatar'),'SmallCountry','Country') as SmallCountry, // Country is field name
"Full Name",

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
niha
Creator II
Creator II
Author

Hello,

Thanks. I tried the code as suggested. I do see the values as Bigcountry, Country and also small country and country . I want the values as given in the match criteria like for Bigcountry I want Italy, France, Spain, UK, to be displayed.

If(Match(Country,'Italy','France','Spain','United Kingdom'),'BigCountry', 'Country') as BigCountry,
If(Match(Country, 'Egypt', 'Jordan', 'Lebanon' , 'Israel', 'Kuwait', 'Qatar'),'SmallCountry','Country') as SmallCountry, Untitled.png

Channa
Specialist III
Specialist III

If(wildMatch(Country,'Italy','France','Spain','United Kingdom'),'BigCountry') as BigCountry,

If(wildMatch(Country,'Egypt', 'Jordan', 'Lebanon' , 'Israel', 'Kuwait', 'Qatar'),'SmallCountry') as SmallCountry

dont use match it is case sensitive 

try these 2

Channa