Hi everyone! I'm relatively new to Alyterx and trying to comprise an IF statement that also nests with an AND statement. I got the formula to work in Excel, but am having trouble converting it to Alteryx. I've read some information about IF ELSE formulas in Alteryx, but I did a separate IF statement (without the AND) and it worked very similarly to how it works in Excel so I was trying to do the same for this. Any help would be appreciated!
iif([Year]=1,DateTimeDiff([End Date1],[Start Date2],"days"),iif([Year]>1 AND [End Date1]>[End Date2],[End Date2]-[Start Date1],[End Date1]-[Start Date1])
Solucionado! Ir para Solução.
Maybe give this a try?
IF [Year] = 1
THEN DateTimeDiff([End Date1],[Start Date2],"days")
ELSEIF [Year]>1 AND [End Date1]>[End Date2]
THEN [End Date2]-[Start Date1]
ELSE [End Date1]-[Start Date1]
ENDIF
Hi! Brandon’s solution might work and I think with written syntax rather than the syntax you use it’s a bit easier to find where the problems are, however in your case I think you are missing a closing bracket at the end. You have too IIF statements and therefor you need to close both.
iif([Year]=1,DateTimeDiff([End Date1],[Start Date2],"days"),iif([Year]>1 AND [End Date1]>[End Date2],[End Date2]-[Start Date1],[End Date1]-[Start Date1]))
Further to this I don’t think Alteryx likes you just doing DATE-DATE and you should use the datetimediff function in all cases.
Ben
Thanks for the responses! I was able to get it to work!
Usuário | Contagem |
---|---|
19 | |
15 | |
13 | |
9 | |
8 |