Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Creating a new field with IF statement

I am working with data on universities. I have two fields for university name linked by an ID tied to the name.  One field is much longer and  I would like to create one field for name where if there is a value in 'name 1' it takes that but if 'name 1' is empty it takes the value for 'name 2'

ID
Name 1Name 2
1UNCUNC
2-USC
3UVA -
4-UGA

Any advice on how to write that to create a new field for name?

Thanks

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi ,

LOAD ID,

    [Name 1],

    [Name 2],

    if(len([Name 1])>1,[Name 1],[Name 2]) as [Final Name]

from file1

Thanks

BKC

View solution in original post

7 Replies
agomes1971
Specialist II
Specialist II

Hi,

in your load data

..

if(Name1='',Name2,Name1) as Name

HTH

André Gomes

PrashantSangle

hi,

try like

if(isnull(Name 1) or len(trim(Name 1))=0,Name 2,Name 1) as Name

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
stigchel
Partner - Master
Partner - Master

Something like:

Load....

....

if(len(Name1)>0,Name1,Name2) as Name

......

from....

Anonymous
Not applicable
Author

Hi ,

LOAD ID,

    [Name 1],

    [Name 2],

    if(len([Name 1])>1,[Name 1],[Name 2]) as [Final Name]

from file1

Thanks

BKC

Anonymous
Not applicable
Author

Hope the attached qvw solves your problem

Not applicable
Author

How can we do the same but if the fields are in different tables?

Not applicable
Author

Hello,

if (Len([Name_1])>1,

                     [Name_1],

                                   [Name_2]) as [UniversityName]

Zain.