Free Trial

Alteryx Designer Desktop Discussions

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

Filtering date range based on condition

johandilipsamuel
5 - Atom

Hi

 

I have a scenario where I am stuck for the last two days

 

I need to filter last week(Sunday to Saturday) based on whatever day it is today because the case may run any day in the week. Whatever day it is, I need to filter only last week. 

4 REPLIES 4
Akash__on
8 - Asteroid

Just provide some sample data and desired output needed.

regards,

aakash

PhilipMannering
16 - Nebula
16 - Nebula

Hi @johandilipsamuel 

 

You could try shoving this expression in a Filter Tool,

tonumber(datetimeformat([date], '%U')) = 
tonumber(datetimeformat(datetimetoday(), '%U')) - 1

 

Let me know if this works!

 

Thanks

PhilipMannering
16 - Nebula
16 - Nebula

Here's the workflow that worked for me....

Adrian_T
Alteryx Alumni (Retired)

Hi @johandilipsamuel,

 

There are a few DateTime Functions that you would have to be using here: DateTimeFormat, DateTimeToday and specifier "%U" which returns week number.

 

The formula below looks up on the week number of Today, then filters your date column by today's week number - 1.

 

IF ToNumber(DateTimeFormat([Date],"%U")) = ToNumber(DateTimeFormat(DateTimeToday(),"%U")) - 1
THEN "Keep"
ELSE Null()
ENDIF

 

 

Sample workflow is attached. Hope this helps!

Adrian_T_0-1655135967416.png

 

Labels
Top Solution Authors