Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem creating new field using IF statement

Hello All,

I am hoping someone can help me, as I am trying to write a formula in my script to create a new field and what I have written below tells me it is wrong when I close the brackets.  I am sure I am missing something simple but just not seeing it.

This is what I have written:- IF("AREA_ID" = '1' or

  IF("AREA_ID" = '5' or

   IF("AREA_ID" = '6' or

    IF("AREA_ID" = '7', 'NORTH',

     IF("AREA_ID" = '2' or

      IF("AREA_ID" ='3' or

       IF("AREA_ID" = '4', 'SOUTH','OTHER'))))))) as DivisionalOpsArea

I tried this as well but it seems to have ignored most of the staement as it only returns a small amount of data saying North.

IF("AREA_ID" like '1' or '5' or '6' or '7', 'NORTH',

IF("AREA_ID" like '2' or '3' or '4', 'SOUTH','Other')) as DivisionalOpsArea

Thanks for any help in advance

Viv

1 Solution

Accepted Solutions
perumal_41
Partner - Specialist II
Partner - Specialist II

Hi,

IF(match(AREA_ID , '1' , '5' , '6' , '7')>0, 'NORTH',

IF(match(AREA_ID , '2' , '3' , '4')>0, 'SOUTH','Other'))  as DivisionalOpsArea.

Try this method in  if statement

View solution in original post

2 Replies
perumal_41
Partner - Specialist II
Partner - Specialist II

Hi,

IF(match(AREA_ID , '1' , '5' , '6' , '7')>0, 'NORTH',

IF(match(AREA_ID , '2' , '3' , '4')>0, 'SOUTH','Other'))  as DivisionalOpsArea.

Try this method in  if statement

Not applicable
Author

u should write the script like this

if(

AREA_ID=1 or AREA_ID=5 or AREA_ID=6 or AREA_ID=7 ,'NORTH',

if(AREA_ID=2 or AREA_ID=3  or AREA_ID=4 ,'SOUTH',

'Others')) as DivisionalOpsArea