2024: Week 24 - Solution
Solution by Tom Prowse and you can download the workflow here.
Step 1 - Weekly Salary
First we want to input the Tenures & Salaries table and then calculate a single row for each week when a salary will be paid. Currently, the salaries are at a yearly total so therefore we first need to calculate this on a weekly basis:
Salary
[Salary]/52
Now we have the weekly total, we can start to create a row for each of the different weeks. For this we can use the 'New Rows' step but first we need to create an end date for our range.
For this we can make sure that the End date is a Date field, and then replace the last date '17/06/2024' with the end date in the requirements '12/06/2024'.
We can then create the new rows step where we create a row between the start and end date for each week:
Step 2 - Output 1
We are now ready to output our first table. For this we need to create a total salary per week so we can create an aggregation step and group by Week then Sum the Salary field.
Within the aggregation you can set the level that you want to aggregate the date by, in our case we want to select the Week Start level:
We can then round the salary to 2 decimal places and rename the field to Salary Payments:
Salary Payments
ROUND([Salary],2)
Then our final table for the first output should look like this:
Step 3 - Output 2
We can now return to the 'New Rows' step and create a new branch off of here using another aggregation step. This time we want to aggregate by the Year and sum the Salary. Again we want to select the level in the group by field:
We can then round the salary and rename the Week field to Year.
Salary
ROUND([Salary],2)
Next we can input and combine the Total Expenses table by using an inner join on the Year field from both tables:
Finally we can calculate the % spent of manager salaries by dividing the salary by the expenses:
% Spent on Manager Salaries
ROUND([Salary]/[Expenses]*100,1)
We can then remove any fields that we no longer need and are ready to output the table:
You can view the outputs here.
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!