Alteryx Designer Desktop Discussions

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

Dynamic Date

Cbennett022
8 - Asteroid

I have a source file that contains a column with various dates. I am needing to identify all data points that fall within the last 12 months, from a specific period. The specific period changes every month.

 

For example, for the month ending March 31,2020 I need to identify every data point that falls within the previous 12 months so anything from April 1, 2019 through March 31, 2020 would be identified.

 

I would want to make the current period date (03/31/2020) to be a dynamic input so the formula would continue to identify relevant dates every time the model is run in subsequent periods. Any and all help is appreciated

3 REPLIES 3
grossal
15 - Aurora
15 - Aurora

Hi @Cbennett022,

 

you could use the following formula in a Filter Tool to achieve it:

 

 

[Date] >= ToDate(DateTimeAdd(DateTimeToday(), -1, "year"))

 

 

The "DateTimeToday()" will always get the date of the day the workflow is exectured. DateTimeAdd with -1 year will always get the Date from one year ago. Compare this to your "Date" Column and you should be good to go.

 

Let me know if this helps. 

 

Best

Alex 

Cbennett022
8 - Asteroid

Thank you for the quick response.

 

One thing to note. the initial date will always be the end of the given month. Is there a way to make the period selection dynamic, where it will update that formula based on the input of the date by the user?

grossal
15 - Aurora
15 - Aurora

Sure!

 

You can use a Date-Picker in combination with a Action Tool to use the Date the user wants.

grossal_0-1586523052599.png

 

One additional thought: You can also use the "DateTimeLastOfMonth" Function to get the last day of a give date.

 

 

Best

Alex

Labels