A weekly challenge to help you learn to prepare data and use Tableau Prep
2021: Week 24 - Solution
Get link
Facebook
X
Pinterest
Email
Other Apps
Solution by Tom Prowse and you can download the workflow here.
The challenge this week was to look at managing unscheduled time off at Chin & Beard Suds Co. In the challenge we are looking to analyse how many people have been off and if we have had someone off every day.
Step 1 - Build Out Dates
The first part of the challenge is to build out our data set so that we cover every date listed between 1st April and 31st March. This is where the scaffold will come in useful as we can use this to fill in any dates that we might be missing in our Reasons data set.
To make sure we are starting on the correct date, we first need to find the first date across our Reasons table. We can do this by using an aggregate tool, and finding the Min Date:
We now want to join this to our scaffold. To do this we need to do a cross join so that each of the rows from table is joined with all of the rows from another. Therefore, we need to create a calculated field to do this, I've just a 1 but this could be anything.
The join looks like this:
Then as a result, our Min Date now has a row from the scaffold
Finally, to make sure that we fill in the rest of the dates, then we need to use a DateAdd function:
Date
DATEADD('day',[Scaffold],[Start Date])
Which fills in the dates between the 1st April & 31st May.
Step 2 - Build Out Days Off
We now need to do a similar process but with the days when people have been off. This time instead of finding the minimum date, we can just use a cross join to our scaffold straight from the reasons table.
Instead of doing a straight cross join (1=1), this time we will use a > join clause to only return the scaffold depending on how many days off someone has had. This will allow us to find the days between the start and end date of their absence.
The join condition looks like this:
We can then use a similar calculation as before to fill in the missing dates:
Date Off DATEADD('day',[Scaffold],[Start Date])
Our days off data will now look like this:
Step 3 - Merge Tables
Now we have built out the dates on each data set, we want to combine these into a single table. To do this we are going to use a Right join where we are returning all of the dates from the first scaffold. The join condition looks like this:
As a result our merged table should look like this:
Step 4 - Number Off Each Day
The final part of the task is to calculate how many people have been off each day. We can use an aggregation tool to find this, where we group by Date, then Count Names:
This will allow us to answer our questions from the challenge:
1. What date had the most people off? - 8th April, 4 people off
2. How many days does no-one have time off on? 35 days
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!
Created by: Carl Allchin Welcome to a New Year of Preppin' Data challenges. For anyone new to the challenges then let us give you an overview how the weekly challenge works. Each Wednesday the Preppin' crew (Jenny, myself or a guest contributor) drop a data set(s) that requires some reshaping and/or cleaning to get it ready for analysis. You can use any tool or language you want to do the reshaping (we build the challenges in Tableau Prep but love seeing different tools being learnt / tried). Share your solution on LinkedIn, Twitter/X, GitHub or the Tableau Forums Fill out our tracker so you can monitor your progress and involvement The following Tuesday we will post a written solution in Tableau Prep (thanks Tom) and a video walkthrough too (thanks Jenny) As with each January for the last few years, we'll set a number of challenges aimed at beginners. This is a great way to learn a number of fundamental data preparation skills or a chance to learn a new tool — New Year...
Created by: Carl Allchin Welcome to a New Year of Preppin' Data. These are weekly exercises to help you learn and develop data preparation skills. We publish the challenges on a Wednesday and share a solution the following Tuesday. You can take the challenges whenever you want and we love to see your solutions. With data preparation, there is never just one way to complete the tasks so sharing your solutions will help others learn too. Share on Twitter, LinkedIn, the Tableau Forums or wherever you want to too. Tag Jenny Martin, Tom Prowse or myself or just use the #PreppinData to share your solutions. The challenges are designed for learning Tableau Prep but we have a broad community who complete the challenges in R, Python, SQL, DBT, EasyMorph and many other tools. We love seeing people learn new tools so feel free to use whatever tools you want to complete the challenges. A New Year means we start afresh so January's challenges will be focused on beginners. We will u...
Free isn't always a good thing. In data, Free text is the example to state when proving that statements correct. However, lots of benefit can be gained from understanding data that has been entered in Free Text fields. What do we mean by Free Text? Free Text is the string based data that comes from allowing people to type answers in to systems and forms. The resulting data is normally stored within one column, with one answer per cell. As Free Text means the answer could be anything, this is what you get - absolutely anything. From expletives to slang, the words you will find in the data may be a challenge to interpret but the text is the closest way to collect the voice of your customer / employee. The Free Text field is likely to contain long, rambling sentences that can simply be analysed. If you count these fields, you are likely to have one of each entry each. Therefore, simply counting the entries will not provide anything meaningful to your analysis. The value is in ...