Registered users of this product or Trifacta Wrangler Enterprise should login to Product Docs through the application.
The following dataset contains orders for multiple customers over a period of a few days, listed in no particular order. You want to assess how order size has changed for each customer over time and to provide offers to your customers based on changes in order volume.
When the data is loaded into the Transformer page, you can use the
PREV function to gather the order values for the previous two orders into a new column. The trick is to order the
window transform by the date and group it by customer:
The two new columns represent the previous order and the order before that, respectively. Now, each row contains the current order (
OrderValue) as well as the previous orders. Now, you want to take the following customer actions:
- If the current order is more than 20% greater than the sum of the two previous orders, send a rebate.
- If the current order is less than 90% of the sum of the two previous orders, send a coupon.
- Otherwise, send a holiday card.
To address the first one, you might add the following, which uses the
IF function to test the value of the current order compared to the previous ones:
send holiday card. Results:
After you drop the
OrderValue_2 columns, your dataset should look like the following. Note that since the transforms with
PREV functions grouped by
CustId, the order of records has changed.
This page has no comments.