A weekly challenge to help you learn to prepare data and use Tableau Prep
2021: Week 34 - Solution
Get link
Facebook
X
Pinterest
Email
Other Apps
Solution by Tom Prowse and you can download the workflow here.
This week was the final instalment of the Excel challenges month, so it seemed like the right time to involve a Vlookup and Index matches as these are such popular features. For the challenge this week we want to compare monthly targets with data stored on another sheet... let's see how we solved it!
Step 1 - Average Monthly Sales
The first step this week is to input the Employee Sales table and then calculate the average monthly sales for each employee. Before using an aggregate tool to calculate the average, we need to pivot our data so that we have all of the months in a single column, therefore we can use a wildcard columns to rows pivot to bring all of the months through:
Now we have a single column for sales and months, therefore we can use the aggregation tool to calculate the average monthly sales per employee:
Our table should now look like this:
Step 2 - Combine Targets & Sales
We can now focus on the targets table and how we combine this with sales table. First we need to do some cleaning of the store field, in the targets input, as some of the stores are spelling incorrectly.
To clean and group these together we can use the Group by Spelling functionality, that will group together the similar store names:
As a result we now have 4 correct store names that are all spelt correctly, so we can now join this to the Sales table using Employee & Store:
Our table now looks like this:
Step 3 - Filter Below 90%
Now we have combined the two tables, we can filter the rows so that we only keep the employees who are below 90% of their target. To do this we can use a calculation within the filter:
[Avg monthly Sales]<([Monthly Target]*0.9)
And then round the sales values to a whole number:
Avg Monthly Sales
ROUND([Avg monthly Sales],0)
Step 4 - Target Met %
Then final task for this week's challenge is to calculate the % of months that the remaining employees met or exceeded their target.
The first step to calculating this, would be to bring back all of the individual monthly sales figures. We can do this by joining the data back to the Pivot step earlier in the workflow, and again joining on Store & Employee.
Our table should now look like this after the join:
Next we need to calculate whether the employee met or exceeded their target for each of the months. We can do this by using the following IF statement:
Met Target? IIF([Sales]>=[Monthly Target],1,0)
Another way of writing this calculation would be:
IF [Sales]>=[Monthly Target] THEN 1 ELSE 0 END
But both will return a 1 or 0 depending if they have met or exceeded their target for the given month.
The final step is to total the number of times that the employees hit their target by using an aggregation tool:
We can then use these totals to calculate the % of total for each employee by using this calculation:
% of months target met ROUND( 100*[Met Target?]/[Month] ,0)
Then after some final tidying we should have a table that matches our output:
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 use dif
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