Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Unable to get the else value by using the formula function

deepsingh
7 - Meteor

Hello,

 

I am applying a simple formula (screengrab below), the formula is not returning me with the else value i.e "0".

 

Not sure what am i missing here, please assist.

 

Thanks!

 

 

IF else function.PNG

7 REPLIES 7
patrick_digan
17 - Castor
17 - Castor

@deepsingh Can you provide an example of a record (the values of OrderID, u11 and Action Name) that you think should be returning "0"? Your formula seems as though it's setup correctly syntax wise.

MarqueeCrew
20 - Arcturus
20 - Arcturus

@deepsingh,

 

Observations:

It looks like you are going to return the values of 0 & 1.  I would use a numeric data type of "Boolean" for these values.  If you want a string "0" and "1", then I would use STRING with a length of 1.

 

The IF statement has 2 conditions being tested.  When either condition is True, or more specifically in any case where the first condition is true plus those conditions where the first condition is false and the second condition is true, then the result is 1.  The default value of 0 is set when the condition tests are not true.

 

Recommendation:

Summarize your data (Group by Order_id, ull, Action Name & count of Order_id) and view the results to see if you should get any 0 results.  The logic itself looks reasonable.  Here is another construction of the logic:

 

IF Contains([Action Name], "HMS_bModify_ORDER")  THEN 0
    ELSEIF !sNull([Order_id]) && !IsNull([ull]) THEN 1
    ELSE 0
ENDIF

I chose to write the statement this way to illustrate that whenever the Action Name includes the "HMS_bModify_Order" text, that you want the value to be 0.  The ELSEIF looks to see if the other variables have ANY value (including space or '') that the result is 1.  The else condition would only occur with a NULL value to either Order_id or to ull.  It doesn't matter what value ull has.  

 

Another statement would be:

 

IF  !IsNull([Order_id]) and !IsNull([ull]) and Contains([Action Name],"HMS_bModify_Order")  THEN 1
ELSE 0
ENDIF

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
deepsingh
7 - Meteor

@

 

I think I have got the answer to this one (the other reply by @

 

 

deepsingh
7 - Meteor

Hello 

 

Thank you for the response.

 

We are still not getting the desired output, also in the actual formula the Action Name is not equal to HMS_bModify_ORDER (The updated formula shown below)

 

IF !IsNull([Order_id]) and !IsNull([u11]) and [Action Name] != "HMS_bModify_ORDER" THEN 1

ELSEif !IsNull([Order_id]) and Contains([u11], "-new") and Contains([Action Name], "HMS_bModify_ORDER") THEN 1

else 0

Endif

 

After the formula we have used select function to change the Broadband field type to Double, we are still getting 1 as a result.

 

Let me know if you need any more details.

 

Thanks!

deepsingh
7 - Meteor

 

 

 

 

 

 

 

 

 

patrick_digan
17 - Castor
17 - Castor

@deepsingh It is working as I expected in the attached. Perhaps you're having an issue with null vs blank in u11? Notice that a true null will produce a 0 in broadband while a blank will produce a 1.

 

nullnull

 

blankblank

deepsingh
7 - Meteor

 

Thank you that worked.

 

Regards,

Deepak Singh

Labels