Hi,
I am new to alteryx and I will appreciate any help offered.
I have a formula in tableau that I want to translate into Alteryx. Please see below. Is it possible to duplicate this formula in Alteryx or is there a shortcut to this? My output goal is to calculate days remaining until due date
if (field1) = 'Data pass' and (field 2) = 'Data fail'
then
(if 730-DATEDIFF ('day',(field 3- state change date), [as of date])
< 0 then 365- DATEDIFF ('day', (field 3- state change date), [as of date])
else 365- DATEDIFF ('day', (field 3- state change date), [as of date]) end)
elseif (field1) <> 'Data pass' and (field2) = 'Data fail' then
(if 730-DATEDIFF('day', (field 3- state change date), [as of date]) < 0
then 730-DATEDIFF('day', (field 3- state change date), [as of date])
else 730-DATEDIFF('day', (field 3- state change date), [as of date])
END)
END
Thank you in advance!
*as of date is a parameter in tableau
Solved! Go to Solution.
Hi @b777
Here is a Tableau Function Translation Guide.
Depending on what kind of data format we are working with, I have provided a sample WF with 2 approaches depending on date formats to achieve the number of days between a certain date and the due date.
DateTimeToday() - expression will provide today's date inside a column which can be used to calculate days to due date if needed.
Thank you Panpp for your response. Question - how do I incorporate IF statement to the solution you provided? Tableau formula has an IF statement in it.
Regards
Hi @b777
It's a similar concept to the conditional statement you used. It would be easier for me to understand if you provide Input data and what your output data should look like.
In Alteryx:
- IF c THEN t ELSE f ENDIF (includes ELSEIF)
- DateTimeDiff(datetime1, datetime2, units)
In Tableau:
- IF c THEN t ELSE f END (includes ELSEIF)
- DATEDIFF(date_part, date1, date2, [start_of_week])
Below are more functions you can view as a reference guide.
Hi @PanPP ,
please see my input data and my output data. Output data should be "Days to Due date"
Input data:
field 1 | field 2 | change of state | Due Date | Current Date | Days to Due Date | |
1 | Data pass | data fail | 12/1/2022 | 12/1/2023 | 12/13/2022 | 353 |
2 | Enhancing | data fail | 11/30/2022 | 11/30/2024 | 12/13/2022 | 718 |
3 | Enhancing | data fail | 11/28/2022 | 11/28/2024 | 12/13/2022 | 716 |
4 | Enhancing | data fail | 11/28/2022 | 11/28/2024 | 12/13/2022 | 716 |
5 | Data pass | data fail | 11/18/2022 | 11/18/2023 | 12/13/2022 | 340 |
6 | Data pass | data fail | 11/18/2022 | 11/18/2023 | 12/13/2022 | 340 |
7 | Data pass | data fail | 11/18/2022 | 11/18/2023 | 12/13/2022 | 340 |
8 | Data pass | data fail | 11/14/2022 | 11/14/2023 | 12/13/2022 | 336 |
9 | Data pass | data fail | 11/14/2022 | 11/14/2023 | 12/13/2022 | 336 |
My end goal is to calculate days going up to due date and days past due date from current date.
Thanks in advance
Hi @b777
I have uploaded a sample WF that I believe achieves the output you are looking for.
Hope this helps.
Hi @PanPP , Thank you so much for taking your time to come up with the solution above. Highly appreciated 😊