
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 1 | Name 2 |
---|---|---|
1 | UNC | UNC |
2 | - | USC |
3 | UVA | - |
4 | - | UGA |
Any advice on how to write that to create a new field for name?
Thanks
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
LOAD ID,
[Name 1],
[Name 2],
if(len([Name 1])>1,[Name 1],[Name 2]) as [Final Name]
from file1
Thanks
BKC


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
in your load data
..
if(Name1='',Name2,Name1) as Name
HTH
André Gomes

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
try like
if(isnull(Name 1) or len(trim(Name 1))=0,Name 2,Name 1) as Name
Regards
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 🙂


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Something like:
Load....
....
if(len(Name1)>0,Name1,Name2) as Name
......
from....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
LOAD ID,
[Name 1],
[Name 2],
if(len([Name 1])>1,[Name 1],[Name 2]) as [Final Name]
from file1
Thanks
BKC

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hope the attached qvw solves your problem

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can we do the same but if the fields are in different tables?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
if (Len([Name_1])>1,
[Name_1],
[Name_2]) as [UniversityName]
Zain.
