Question for formula

YukiN
YukiN Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 12 Dataiker

Hello,

I have data with columns "Date", "Cusotmer" and "This month purchase count" as shown in the table below, is it possible to calculate the "Last month purchase count" with the Prepare recipe?

DateCustomerThis Month Purchase CountLast Month Purchase Count
May-22A51
May-22B34
May-22C76
Apr-22A12
Apr-22B45
Apr-22C61
Mar-22A2 
Mar-22B5 
Mar-22C1 
Tagged:

Answers

  • Zach
    Zach Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 153 Dataiker

    Hi @YukiN
    ,

    You can do this using a Window recipe.

    If your Date column is a string, first you'll need to parse it to a date. You can do this by using a "Parse date" step in a Prepare recipe as shown below:

    B4E0BAB2-7968-4FB4-97ED-15681B517182_1_201_a.jpeg

    Be sure that the type of the column is set to "date" (highlighted above).

    Once you have a parsed date column, you can create a Window recipe with the following settings:

    Window definitions:E28393A7-C34D-4224-A335-655AE7871C23.png

    Aggregations (be sure to select the "Lag" aggregation):

    34D4F658-6786-4052-8886-6D0483C60E89.png

    Here's what the output dataset looks like:

    36DEDEE9-1CCF-4B95-AFC6-BA0A78B58DBB.png

    Reference documentation:

    Thanks,

    Zach

  • YukiN
    YukiN Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 12 Dataiker

    Wow, thank you very much @ZachM
    !! I could do it.

Setup Info
    Tags
      Help me…