The web team wants to promote which style of product has sold the most units in the last hour in a new “trending product” section of their home page.
This is an extension to the Track how many products of each type are sold per hour tutorial. In that tutorial, we counted how many units of each product type are sold in each hour.
To refine the previous tutorial flow, this tutorial shows you how to identify the style with the highest number of units sold per hour.
This tutorial was written using the following versions of Event Automation operators. Screenshots may differ from the current interface if you are using a newer version.
- Event Processing 1.1.1
Step 1 : Create a flow
This tutorial begins with the flow that was created in the Track how many products of each type are sold per hour tutorial, which gives an hourly count of the number of units that are sold of each style.
If you haven’t completed that tutorial yet, you should do it now.
Run the flow to remind yourself of the output.
When you have finished reviewing the results, you can stop this flow.
Step 2 : Identify the best selling style
The next step is to identify the best selling product type in each hour.
Add a Top-n node.
Link the top-n node to the aggregate node.
Call the Top-n node
top selling style.
Reuse the time window already defined in the previous aggregate node: 1 hour.
Specify which property to sort results by (total sales) and how many results to keep (1).
If you wanted to keep the top three selling styles for each hour, for example, you would set this to 3.
Choose the output properties that will be useful to return.
Click Configure to finalize the top-n.
Step 3 : Test the flow
The final step is to run your event processing flow and view the results.
Every hour an event will be emitted with the name of the best selling style in the previous hour, and the total number of units sold.
The web team can use this to drive a trending products section on their web page to promote something that is currently selling a lot of items.