Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Nested IF THEN and Greater than or Equals Statements - Unknown Variable

rgalik
7 - Meteor

Good Morning, 

 

I am trying to utilize this formula to compare data between two columns and then return a specific result. When I ran the formulas individually they worked fine, however they would read everything that didn't fit that formula as a 'Flag' 

Here is my formula. Am I getting something wrong with the syntax?

 

I have created a new column called 'Employee Hours Flag'

 

if [Hours] < 30000 AND [EMPLOYEE] >= 1 THEN ''
ELSEIF [Hours] < 69999 AND [EMPLOYEE] >= 2 THEN [Employee Hours FLAG]
ELSEIF [Hours] > 70000 AND [EMPLOYEE] >= 2 THEN [Employee Hours FLAG]
ELSE 'FLAG' ENDIF

6 REPLIES 6
afv2688
16 - Nebula
16 - Nebula

if [Hours] < 30000 AND [EMPLOYEE] >= 1 THEN ''
ELSEIF [ Hours] < 69999 AND [EMPLOYEE] >= 2 THEN [Employee Hours FLAG]
ELSEIF [ Hours] > 70000 AND [EMPLOYEE] >= 2 THEN [Employee Hours FLAG]
ELSE 'FLAG' ENDIF

 

Hours are different variables there. First line has no space, second and third has a space before the 'H'

rgalik
7 - Meteor

Thank you for your speedy reply. 

 

I had to alter the names of Hours due to sensitive data. There are no additional spaces in the original formula. 

 

My apologies. 

 

afv2688
16 - Nebula
16 - Nebula

Could you share a little table in here with a few examples that are giving you the error? Typing only the 3 necessarycolumns on your formula.

afv2688
16 - Nebula
16 - Nebula

There is something bothering me: 

 

"""""""""""""""""""""""""""""""""""""""""""""""""""""""

I have created a new column called 'Employee Hours Flag'

 

if [Hours] < 30000 AND [EMPLOYEE] >= 1 THEN ''
ELSEIF [Hours] < 69999 AND [EMPLOYEE] >= 2 THEN [Employee Hours FLAG]
ELSEIF [Hours] > 70000 AND [EMPLOYEE] >= 2 THEN [Employee Hours FLAG]
ELSE 'FLAG' ENDIF

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

The colum you are creating on the formula tool (which I suppose is a new one) is the same one you are using on the formula itself? I mean, if it was there before then everything is ok, but if not you cannot use it.

 

On the other side, if I'm wrong and thats not the case the formula is well written. I did use it with some dummy data and for me it works.

 

Would need as I said some data or the error that the WF is giving you to help you further.

 

Regards

rgalik
7 - Meteor

Surely, 

 

So the Employee Flag column is a new column per the formula tool.

 

HoursEmployeeEmployee FLAG
50001 
150001 
5001 
12002 
4001 
750001 

 

Here is some sample data. I need the formula to read the hours and employee column see if they fit the criteria and then flag them if they do not. The Employee numbers will not always be 1 or 2.

rgalik
7 - Meteor

That was it, I was trying to manipulate data in a column that hadn't been created yet. 

 

I changed the [Employee FLAG] column to '' and it worked fine. Thank you!

 

Labels