Alteryx Designer Desktop Discussions

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

Tableau formula to alterxy formula

b777
6 - Meteoroid

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

6 REPLIES 6
PanPP
Alteryx Alumni (Retired)

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.

 

 

b777
6 - Meteoroid

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

PanPP
Alteryx Alumni (Retired)

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.

 

Alteryx Functions

Alteryx Conditional Functions

 

 

b777
6 - Meteoroid

 

Hi @PanPP ,

 

please see my input data and my output data. Output data should be "Days to Due date"

 Input data: 

  • if field 1 is = Data pass and field 2 is data fail, I want to add 12 months or 365 days to "change of state" date to calculate due date and then subtract "current date" to populate "days to due date"
  • if field 1 is not equal to Data pass and field 2 is still data fail, I want to add 24 months or 730 days to "change of state" date to calculate due date and then subtract "current date" to populate "days to due date"
 field 1field 2change of stateDue DateCurrent DateDays to Due Date
1Data passdata fail12/1/202212/1/202312/13/2022353
2Enhancingdata fail11/30/202211/30/202412/13/2022718
3Enhancingdata fail11/28/202211/28/202412/13/2022716
4Enhancingdata fail11/28/202211/28/202412/13/2022716
5Data passdata fail11/18/202211/18/202312/13/2022340
6Data passdata fail11/18/202211/18/202312/13/2022340
7Data passdata fail11/18/202211/18/202312/13/2022340
8Data passdata fail11/14/202211/14/202312/13/2022336
9Data passdata fail11/14/202211/14/202312/13/2022336

 

My end goal is to calculate days going up to due date and days past due date from current date.

 

Thanks in advance

PanPP
Alteryx Alumni (Retired)

Hi @b777 

 

I have uploaded a sample WF that I believe achieves the output you are looking for.

 

Hope this helps. 

b777
6 - Meteoroid

Hi @PanPP , Thank you so much for taking your time to come up with the solution above. Highly appreciated 😊

Labels