community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
SOLVED

Multiple IF Conditions

Atom

Hi,

 

 I would appreciate some help. may I know the right formula if in excel the formula is the following ( =IF(H2<>"(blank)",H2,IF(F2<>"(blank)",F2,IF(G2<>"(blank)",IF(M2<>"(blank)",M2,"(blank)"),"(blank)"))) what should i use in alteryx?.

 

Thank you so much in advance.

Pulsar

Hi @bods!

 

Try using the below expression in a Formula tool and see if that gets you what you're looking for. If not, please provide sample before and after data, and we can assist further.

iif([H]!="",[H],iif([F]!="",[F],iif([G]!="",[G],iif([M]!="",[M],""))))

 

Capture.PNG

 

 

NOTE: You could also change all of the [FieldName]!="" sections to !isempty[FieldName]. This would account for if the field is blank or null. That expression would look like this:

iif(!isempty([H]),[H],iif(!isempty([F]),[F],iif(!isempty([G]),[G],iif(!isempty([M]),[M],""))))
Atom

Its work. Thank you so much for helping me

Alteryx Certified Partner
Alteryx Certified Partner

@bods,

 

I would like to add another solution possibility for your consideration.  While it is possible to "convert" the Excel code into an Alteryx formula, I find that the result is somewhat hard to read.  @BarnesK provided you with a solution that obviously works.  Please take a look at this alternative formula:

 

IF 
	!IsEmpty([H]) THEN [H]	ELSEIF
	!IsEmpty([F]) THEN [F]	ELSEIF
	!IsEmpty([G]) THEN [G]	ELSE
	[M]
ENDIF

If I had to explain the code to my boss/Mom/child/anyone without an Excel background, I think that this formula would be less time consuming to explain.  In fact, you can comment the formula too and make it even easier.

 

IF 
	!IsEmpty([H]) THEN [H]	ELSEIF	//Take data from the first column
	!IsEmpty([F]) THEN [F]	ELSEIF	//Resort to the second column if 1 is empty
	!IsEmpty([G]) THEN [G]	ELSE	//Settle for the third column if 2 is empty
	[M]				//You're stuck with the 4th column now
ENDIF

Cheers,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and reboot. Order shall return.
Highlighted
Atom

Thank you Mark! I'll will try this too.

Labels