2021: Week 33 - Solution
Solution by Tom Prowse and you can download the workflow here.
This week we continued with our Excel themed challenges by looking at how we could add some additional rows within Tableau Prep. In Excel this is easily done, but it takes some slightly different logic to achieve this in Prep so let's see how it can be done!
Step 1 - Create One Data Set
Step 2 - Min & Max Dates
Next we need to find the Min and Max dates where each order appeared. We can use an aggregate tool to do this by grouping by Orders & Sale Date and then finding the Min and Max of the Reporting Date.
From here we can then add 1 week to the max date to show when the order was fulfilled by, using the following calculation:
Fulfilled Date
DATEADD('week',1,[Max Reporting Date])
Step 3 - New Order or Fulfilled Logic
This helps us to identify when the first date of each order is, and therefore classify these as New Orders.
Our table should now look like this:
We also need to calculate the status of the fulfilled orders. To do this we want to go back to the step where we added 1 week to our reporting dates, and then add a new string calculation of 'Fulfilled'. This will classify all of these orders as 'Fulfilled'.
Now we can bring both of these branches together into a single table by using a union tool. This will stack both tables on top of each other and combine them together. The combined table should look like this:
Step 4 - Remove Rows
The final step is to remove any of the rows that don't match the logic in the requirements. To do this we want to find out the max reporting date for each order. This can be calculated with a fixed LOD calculation:
Max Report Date
From here we can then calculate whether the order is actually unfilled or not, buy using the following calculation:Actually Unfulfilled?
IF [Max reporting date] = [Reporting Date] AND [Order Status] = 'Fulfilled' THEN 'Delete' ELSE 'Retain' END
This helps to provide the correct status based on the logic in the requirements, and then we can filter the 'Delete' rows from our table so we have the final output that looks like this: