2021: Week 40 - Solution
Solution by Tom Prowse and you can download the workflow here.
This week we some pet data from the Austin Animal Center and we look at how successful they are at find new adoptions for their animals.
Step 1 - Filter for Cats & Dogs
First we need to input the table from the input, at this stage we can remove the duplicated date field from the input options by unselecting MonthYear:
Then create a new step where we can use the filter to 'Keep Only' cat and dog from the Animal Type field. We can do this by selecting both values and then pressing the 'Keep Only' button.
Step 2 - Group Adopted & Other
Next we want to group all of the different outcomes so that we have two categories:
- Adopted, Returned to Owner, or Transferred
- Other
We can do this by using the grouping functionality within Tableau Prep. There are a few ways of doing this but we have used a manual grouping to select the 'Adoption, Returned to Owner, & Transfer' values from the Outcome Type and then rename these to be 'Adopted, Returned to Owner or Transferred' and then the remaining values become 'Other'.
After the grouping, we should now have two values in the Outcome Type field, so next we want to use an aggregation tool to total the number of cats and dogs in each category. Within the aggregation tool we group by Animal Type and Outcome Type and then Sum the Number of Rows field.
Step 3 - Calculate % of Total
The final step for this week is to calculate the % of total for each Outcome Type and Animal. We have the totals for each, therefore we need to calculate the overall total and then use this to find the % of total for each row.
To calculate the total we need to use a fixed LOD:
Total Rows
% of Total
ROUND(
100*[Number of Rows (Aggregated)]
/
[Total Rows]
,1)
After this our table should now look like this:
The final step is to structure the table in the same way as the output. To do this we want to use a rows to columns pivot with the following setup:
After the pivot we have the data in the correct format so we are ready to output!
After you finish the challenge make sure to fill in the participation tracker, then share your solution on Twitter using #PreppinData and tagging @Datajedininja, @JennyMartinDS14 & @TomProwse1
You can also post your solution on the Tableau Forum where we have a Preppin' Data community page. Post your solutions and ask questions if you need any help!