Alteryx Designer Desktop Discussions

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

Filtering Data Based on Previous Month

LorenzTaylor
7 - Meteor

Hello -

This may be a simple question.


I have an historical dataset that goes back multiple Years. I Would like to filter this data set to only show the previous Months Data in the workflow. The main reason I do not want to set a constant date is because every time the workflow runs, it needs to pull the previous months data. For example it is 05-09-2024, this workflow will need to pull all data from (04-01-2021) - (04-30-2024). If the date is currently (06-01-2024), this workflow will need to pull (05-01-2024) - (05-31-2024).

Please see attached for desired output.

3 REPLIES 3
Luke_C
17 - Castor

Hi @LorenzTaylor 

 

Try this in a custom filter: 

[Date] >= todate(datetimetrim(datetimeadd(datetimenow(),-1,'month'),'firstofmonth'))

and 

[Date] <= todate(datetimetrim(datetimeadd(datetimenow(),-1,'month'),'lastofmonth'))
cmcclellan
13 - Pulsar

Hi @LorenzTaylor 

 

Put this is in a filter:

DateTimeAdd(DateTimeTrim(DateTimeToday(), 'month'),-1,'month') = DateTimeTrim([Date], 'month')

 

It's basically saying what you asked - take today's date (ie 5/10), trim it to month (ie 5/1) subtract a month (ie 4/1) and compare to your data that's been trimmed to month as well 

Swathi
9 - Comet

May be you want to convert the dates to Alteryx default format of YYYY-MM-DD before you use the above solutions.

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels