- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
lxm30
New Member
05-31-2019
12:00 PM
I have two fields and if field1 is empty, I want to use the value in field2. (i.e. I never want to use field2 unless field1 is empty).
I was trying to use a coalesce function but it doesn't work well with null values.
Do I have any options beyond using fillnull for field2 with a value of *, coalescing the two and then using rtrim to get rid of the star?
1 Solution
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
martinpu
Communicator
05-31-2019
12:57 PM
Try this
|eval field3=case(isNotNull(field1),field1,isNotNull(field2),field2,1=1, NULL)
should return field 3 as field1 if it isnt null,field2 if that isnt null and field1 is null and NULL if both are NULL
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
martinpu
Communicator
05-31-2019
12:57 PM
Try this
|eval field3=case(isNotNull(field1),field1,isNotNull(field2),field2,1=1, NULL)
should return field 3 as field1 if it isnt null,field2 if that isnt null and field1 is null and NULL if both are NULL
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
lxm30
New Member
05-31-2019
05:50 PM
This works great - thanks so much for the quick response!
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
lxm30
New Member
05-31-2019
12:22 PM
(By * I mean some value, not necessarily the character "*").
