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...
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 ...
Created by: Carl Allchin It's the second week of our introductory challenges. This week the challenge will involve unions, aggregation and reshaping data. Input The input data set for this week is the output from week one. You can download them here . Requirements Input the two csv files Union the files together Convert the Date field to a Quarter Number instead Name this field Quarter Aggregate the data in the following ways: Median price per Quarter, Flow Card? and Class Minimum price per Quarter, Flow Card? and Class Maximum price per Quarter, Flow Card? and Class Create three separate flows where you have only one of the aggregated measures in each. One for the minimum price One for the median price One for the maximum price Now pivot the data to have a column per class for each quarter and whether the passenger had a flow card or not Union these flows back together What's this you see??? Economy is the most expensive seats and first class is the cheapest? When you go and ...