Dynamic Date filter based on current date

JimCreech
Level 1
Dynamic Date filter based on current date

First, https://community.dataiku.com/t5/Using-Dataiku/Dynamic-date-filter/m-p/6171#M3709 will not work for my situation because I do not have a date field that will always contain the current date.

I need to build a filter that will change based on the date the report is run.  The filter is a lagged value based on the current date [between (current date - 21 days and current date -14 days)].    I have solutions outside of DSS, but not within.  The reason for a within DSS solution is that I can automate the process with a dynamic filter for interim reporting.

Thank you in advance for any assistance.

0 Kudos
4 Replies
NN

Hi @JimCreech ,
You can use the date functions in DSS formula in some recipes for example the prepare recipe
https://doc.dataiku.com/dss/latest/formula/index.html#date-functions

One of the other ways we do it is,
we create a scenario and add a define PROJECT variables  or define SCENARIO variables step
and then use the DSS forumla to get the date range as below basis the current date.
The variables ${start_date} and ${end_date} can then be used across recipes. 
But yes everytime you would have to use to the scenario to run your flow.

img1.jpg

JimCreech
Level 1
Author

Thank you.  I will try this along with Ashley's 

0 Kudos
AshleyW
Dataiker

Hi @JimCreech ,

You may also want to check out dynamic date filters in the Prepare's 'filter rows/cells on date' processor. There you can set a filter to run against a date range that is relative to when the recipe is run (last N days, next N days, etc). This will let you run a relative date filter with one condition.

For the one you've outlined with two conditions "between 14 and 21 days ago", you might try a 'filter rows/cells with formula' processor with a formula like diff(now(), date_field, 'day')>14 && diff(now(), date_field, 'day')<21, modifying the >/< if you want the endpoints of the range to be inclusive or exclusive.

Cheers,

Ashley

JimCreech
Level 1
Author

Thank you.  I will try along with Neuron's

0 Kudos