2021: Week 34 - Solution

 


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: 



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! 

Popular posts from this blog

2023: Week 1 The Data Source Bank

2023: Week 2 - International Bank Account Numbers

How to...Handle Free Text