Help I am a new student learning Alteryx and I am trying to convert the following SQL Query to Alteryx:
Any insight and assistance will be greatly appreciated. Thank you.
CASE WHEN AFFECTED_FAM_MEMBER = 'EMPLOYEE' THEN DATEADD(DAY, 9, COVID_ENTRY_DATE) ,
WHEN AFFECTED_FAM_MEMBER = 'FAMILY' THEN DATEADD(DAY, 7, COVID_ENTRY_DATE)
ELSE 'UNKNOWN'
END AS 'Work_Return_Date'
FROM [dbo].[JULY_COVID DATA]
Hi @elsa2020,
I'm not a SQL expert but it looks like you'll need an Input tool to bring in the JULY_COVID DATA from your dbo. Then you'll want a Formula tool where you Add a Column ('Work_Return_Date') and a very similar formula to what you already have:
IF [AFFECTED_FAM_MEMBER]='EMPLOYEE' THEN DateTimeAdd( [COVID_ENTRY_DATE], 9, 'day')
ELSEIF [AFFECTED_FAM_MEMBER = 'FAMILY' THEN DateTimeAdd( [COVID_ENTRY_DATE], 7, 'day')
ELSE 'UNKNOWN'
ENDIF
You may need an extra step before the Formula tool (with a select tool) to check that the Date Column is reading as a date (data type). If not, then you can use the DateTime tool to convert it from a String type to a Date type.
Hope that helps!
Hi @elsa2020 ,
As others have noted, you'll want to start with getting your data into Alteryx using an Input Data tool. In the event that you opt not to copy and paste the query directly into the SQL editor per @Qiu 's suggestion and want to use a formula, you can either follow @ehughes 's suggested formula or use a SWITCH statement in the formula tool. A switch statement is very similar to a case statement, so you might be more comfortable with it.
Switch([AFFECTED_FAM_MEMBER],'UNKNOWN',
'EMPLOYEE',DATEADD([DAY],9,[COVID_ENTRY_DATE]),
'FAMILY',DATEADD([DAY],7,[COVID_ENTRY_DATE]))
As I'm sure you're gathering, there are a lot of ways to accomplish the same thing within Alteryx! Let me know if you have additional questions.