Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Conditional Statements with Nulls

jalizmaldonado
8 - Asteroid

Hi team, I hope all is well. I'm trying to join two fields together - memo code and memo amount - so that I can then concatenate all memo codes and memo amounts for each subject. I've been trying to find as many conditional statement trainings as possible to better understand what I'm doing wrong but I can't seem to get over this obstacle.

 

Not all employees have memo codes and deductions, I'd like to ignore null values and bring memo code and memo amount together: Memo Code: Life Insurance Memo Amount: 10.00 Memo Code: 401K Memo Amount: 10.00

Column 1 - Life Insurance: 10.00

Column 2 - 401k: 10.00

Then

Column 1 - 

Life Insurance: 10

401k: 10.00

 

Here's the statement I wrote: 

 

IF IsNull([Memo Code]) then ""
elseif
IF [Memo Code] THEN
Tostring([Memo Code])+" : "+([Memo Amt])
ELSE
""
endif

 

Please let me know if you're able to help. Thanks so much. 

6 REPLIES 6
Emil_Kos
17 - Castor
17 - Castor

HI @jalizmaldonado,

 

I found two mistakes:

 

IF IsNull([Memo Code]) then ""
elseif
[Memo Code] THEN
Tostring([Memo Code])+" : "+Tostring([Memo Amt])
ELSE
""
endif

 

If you are using elseif you don't need IF anymore. 

I am not sure but you migh need to use Tostring twice but it depends on the data set.

 

Please mark my post as a solution if this was helpful.

Good Luck!

atcodedog05
22 - Nova
22 - Nova

Hi @jalizmaldonado 

 

Adding to @Emil_Kos solution.

 

It is safe idea to use IsEmpty() in place of IsNull(). IsEmpty() catched both Null and Blanks

 

Hope this helps 🙂

atcodedog05
22 - Nova
22 - Nova

Hi @jalizmaldonado 

 

By seeing your condition block. I could get a feel that you were trying to convert excel formula to alteryx formula.

 

Altery IIF() function which exactly works like excel IF() function.

 

https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/Conditional-Statements-Using-IIF-in...

 

Which would make your conversion easier. Hope this helps 🙂

jalizmaldonado
8 - Asteroid

Hi Emil, I hope all is well. I copied over your formula but when I ran the workflow, it did not actually combine the memo code and amount. Alteryx accepted the formula in the configuration section but nothing happened. 

jalizmaldonado
8 - Asteroid

Hi, I hope all is well. 

 

I added your recommendation:

 

IF IsEmpty([Memo Code]) THEN "" ELSEIF [Memo Code] THEN
Tostring([Memo Code])+" : "+Tostring([Memo Amt])
ELSE
""
endif

 

However, the combination of the memo code and memo amount did not work. Any other recommendations? 

Hi @jalizmaldonado 

 

I think the issue is that you don't have a condition for Memo code when it's not blank (this part: ELSEIF [Memo Code] THEN)

 

Please try:

IF IsEmpty([Memo Code]) THEN ""

Else
Tostring([Memo Code])+" : "+Tostring([Memo Amt])
ENDIF

Labels