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

How can we write the below code in alteryx

PNC97
8 - Asteroid

    #"Added -VTO-adjust punch in" = Table.AddColumn(#"Expanded CSSM - schedule VTO", "VTO-adjust punch in", each if [#"Punch-In-vto"] <> null then (if [#"Punch-In"] < [#"Punch-Out-vto"] and [#"Punch-Out"] > [#"Punch-In-vto"] then(

 

 

if [#"Punch-In"] >= [#"Punch-In-vto"] then [#"Punch-In-vto"] else [#"Punch-In"]

 

 

)else [#"Punch-In"])

 

else [#"Punch-In"]),

    #"Added -VTO-adjust punch out" = Table.AddColumn(#"Added -VTO-adjust punch in", "VTO-adjust punch out", each if [#"Punch-Out-vto"] <> null then (if [#"Punch-In"] < [#"Punch-Out-vto"] and [#"Punch-Out"] > [#"Punch-In-vto"] then(

 

 

if [#"Punch-Out"] <= [#"Punch-Out-vto"] then [#"Punch-Out-vto"] else [#"Punch-Out"]

 

 

)else [#"Punch-Out"])

 

else [#"Punch-Out"]),

5 REPLIES 5
mceleavey
17 - Castor
17 - Castor

HI @PNC97 ,

 

If you could post some data and what you are trying to achieve that would be easier for us to help you.

 

Thanks,

 

M



Bulien

Erin
10 - Fireball

Hi @PNC97 ,

 

Agree with @mceleavey that would be easier if some data was available. However, note that nested if statements in Alteryx work a little different: 

 

If [Logical Test 1] then [Value Test 1 True]

Elseif [Logical Test 2] then [Value Test 2 True]

Elseif [Logical Test 3] then [Value Test 3 True]

.......

Else [Value if False] Endif

 

Hope that helps.

 

Erin

PNC97
8 - Asteroid

Input is below table

 

Employee IDEvent DatePunch-InPunch-OutPunch-In-vtoPunch-Out-vto
14/21/202114.1166666715.01666667811
24/5/202110.5333333312.499.5
34/5/202113.383333331899.5
44/5/20219.0166666679.51666667916
54/5/20219.9833333312.55916
64/5/202113.5166666716.73333333916
74/6/20218.0833333339.03333333399.5
84/6/20219.7333333311.5833333399.5
94/6/202114.0166666715.6666666799.5

 

 

Output expected 

 

Employee IDEvent DatePunch-InPunch-OutPunch-In-vtoPunch-Out-vtoVTO-adjust punch inVTO-adjust punch out
14/21/202114.1166715.016666781114.1166666715.01666667
24/5/202110.5333312.499.510.5333333312.4
34/5/202113.383331899.513.3833333318
44/5/20219.0166679.51666667916916
54/5/20219.98333312.55916916
64/5/202113.5166716.7333333916916.73333333
74/6/20218.0833339.0333333399.58.0833333339.5
84/6/20219.73333311.583333399.59.7333333311.58333333
94/6/202114.0166715.666666799.514.0166666715.66666667

 

 

I tried using this as a formula,

But, the output which I got is incorrect

 

For VTO-adjust punch in: 1st format

 

IF [Punch-In-vto] != Null() THEN [Punch-In] ELSEIF [Punch-In] < [Punch-Out-vto] && [Punch-Out] > [Punch-In-vto] THEN [Punch-In] ELSEIF [Punch-In] >= [Punch-In-vto] THEN [Punch-In-vto] ELSE [Punch-In] ENDIF

 

And For VTO-adjust punch out: 2nd format

 

IF [Punch-Out-vto] != Null() AND [Punch-In] < [Punch-Out-vto] AND [Punch-Out] > [Punch-In-vto] AND [Punch-Out] <= [Punch-Out-vto] THEN [Punch-Out-vto] ELSE [Punch-Out] ENDIF

 

 

 

I have given Input and output expected 

 

Thanks in advance.

 

PNC97
8 - Asteroid

With the below formulas the output which i got is incorrect

Qiu
21 - Polaris
21 - Polaris

@PNC97 
I can reproduce these two colummns by just copying your formula with some data cleansing.

 

VTO-adjust punch inVTO-adjust punch out

4A.PNG

Labels