2020: Week 21 - Solution
You can find our full solution workflow below and download it from the Preppin' Data Community page!
For week 21 we were looking at a variety of different metrics in order to do some competitor analysis. These metrics included
- Market Share = Company Sales / Total Market Sales
- Growth = (This Month Sales - Last Month Sales) / Last Month Sales
- Contribution to Growth = (This Month Sales - Last Month Sales) / Overall Last Month Sales
- Outperformance = Company A's Growth - The Growth of the Rest of the Market excluding Company A
Output 1
Step 1 - Calculate Total Sales
After inputting the data source, the first step for Output 1 is to use an aggregation tool to calculate the Sum of Sales by Company and Month. The setup for the aggregation will look like this:
Once we have aggregated the sales by month and company, we can then use a Rows to Columns pivot to get the monthly sales into a column of their own. The pivot setup looks like this:
We now have a row for each of our companies, with their monthly sales in a separate column:
Step 2 - Calculate Market Share & BPS Change
First we want to find the total sales across all of the companies for each month, we can do this by using a LOD calculation that looks like this:
Total March
Total April
Now we have the total for each month, and the monthly sales for each company we are able to calculate the Market Share. To do this we use the following calculations for each month:
March Market Share
[March]/[Total March]
April Market Share
[April]/[Total April]
Once we have calculated both of these, we can use them to calculate the BPS change by using the following calculation:
Round(([April Market Share]-[March Market Share])*10000)
We need to make sure we round our calculation so that this matches the desired outcome.
Step 3 - Calculate Growth
The final calculation that we need for this output is growth and market growth. First we can calculate growth per company:
Growth
([April]-[March])
/
[March]
We can then calculate growth for the all companies:
Market Growth
([Total April]-[Total March])
/
[Total March]
The final step for the first output is to clean and format some of the fields. We want to do the following:
- April Market Share - Multiply by 100, then round to 2 decimal places
round(100*[April Market Share],2)
- Growth - Multiply by 100, round to 2dp, add % symbol
left(str(round(100*[Growth],2)),4)+"%"
- Remove the following fields:
- March
- April
- Total March
- Total April
- March Market Share
- Market Growth
After these changes we are left with out desired output:
Output 2
Step 1 - Calculate Contribution to Growth
Similar to the first output we are going to use a Rows to Columns pivot to create a column for each of our monthly sales. The setup is the sames as before, but this time the Soap Scent will be included in our table. The pivot looks like this:
Next, we want to split the workflow into two streams; one for C&BS and another for the rest of the market.
C&BS Branch
Within this branch we want to isolate just 'Chin & Beard Suds Co', therefore we want to right click on that row and 'Keep Only' so we are left with just the single company.
Next we need to calculate the total sales for March, we can do this by using an LOD calculation like we did in the previous output:
Total March
Now we can use the total for march to calculate the contribution to growth:
C&BS Co Contribution to Growth
round(
100*([April]-[March])
/
[Total March]
,2)
Finally, the only two fields that we need to keep are the Soap Scent and the C&BS Co Contribution to Growth, and our table should look something like this:
Rest of Market Branch
Within this branch we are going to calculate the same, but for the rest of the market. Therefore our first step is to exclude 'Chin & Beard Suds Co' from the company list.
As we have multiple companies, we then want to use an aggregate tool to find the monthly totals for each month. The aggregation tool setup should be like this:
We are now ready to calculate the contribution to growth for the rest of the companies. Therefore, first we need to calculate the total sales for March across all scents. We can use an LOD for this:
Total March
Then we can calculate the contribution to growth:
Rest of Market Contribution to Growth
round(
100*([April]-[March])
/
[Total March]
,2)
Then finally we just want to keep the Soap Scent and Rest of Market Contribution to Growth, and our table should look like this:
Step 2 - Calculate Outperformance
Now we have calculated the contribution to growth in both of the branches, it's now time to bring these back together. We can do this by using an inner join on Soap Scent:
Then the final step before the output is to calculate the Outperformance with the following calculation:
round(([C&BS Co Contribution to Growth]-[Rest of Market Contribution to Growth]),2)
We need to round our answer so that this matches the output that is required and our final table for this should look like this:
Make sure to fill in the participation tracker, share using #PreppinData on Twitter and post you solutions onto our Tableau Forums community page so that we can compare our workflows!