Dynamic Date filter based on current date

JimCreech
JimCreech Registered Posts: 5 ✭✭✭

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.

Answers

  • NN
    NN Neuron, Registered, Neuron 2022, Neuron 2023 Posts: 145 Neuron

    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

  • Ashley
    Ashley Dataiker, Alpha Tester, Dataiku DSS Core Designer, Registered, Product Ideas Manager Posts: 161 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
    JimCreech Registered Posts: 5 ✭✭✭

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

  • JimCreech
    JimCreech Registered Posts: 5 ✭✭✭

    Thank you. I will try along with Neuron's

Setup Info
    Tags
      Help me…