Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
NataliaD
Contributor
Contributor

Create column based on multiple conditions WITHOUT nested if

Hello,

I want to create a column named Status having Character Values in a straight table based on other fields, i.e.

if column A = 'a' return Status = 'a',
    if not then check column B, if column B = 'b' return Status = 'b',
        if not then check column C, if column C = 'c' return Status = 'c',
             if not return Status = 'w'

I've also attached an image explaining this.

The problem is that I do NOT want to use nested If, because it takes too long to execute, so I try to find a way using Set Analysis, but I cannot understand how. 

Thank you!

4 Replies
Taoufiq_Zarra

@NataliaD  May be this help :

Dimension: A,B,C

Expression:

=pick(Match(left(A&B&C,1),'','a','b','c'),'w','a','b','c')

 

output:

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
NataliaD
Contributor
Contributor
Author

Thank you, I'll try it! But I have another problem that I forgot to mention. Column C has two values so how can I write them both ? because you wrote 'c' but there are two values I want to check..

Kushal_Chawda

@NataliaD  try below. Where a,b and c are your 3 fieldnames

if(len(trim(subfield(a&'_'&b&'_'&c,'_',1)))>0,subfield(a&'_'&b&'_'&c,'_',1),
if(len(trim(subfield(a&'_'&b&'_'&c,'_',2)))>0,subfield(a&'_'&b&'_'&c,'_',2),
if(len(trim(subfield(a&'_'&b&'_'&c,'_',3)))>0,subfield(a&'_'&b&'_'&c,'_',3),'W'))) as TEST

 

Brett_Bleess
Former Employee
Former Employee

@NataliaD  be sure to remember to return to the thread to close things out if one of the two suggestions helped by using the Accept as Solution button on the post(s) that helped, you can mark more than one post, just FYI.  If you did something different, you can post what you did and then mark that post too.  It will be greatly appreciated if you can close the thread if you have figured out a solution.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.