2023: Week 46 - Solution




Solution by Tom Prowse and you can download the workflow here



Step 1 - Minutes Late

After inputting the data we want to remove any null values from the Arrival Time. We can do this by selecting the 'Null' value in the profile pane and then exclude.

We can then create the Scheduled Start Time and Arrival Time by combining the date with each of the time fields.

Scheduled Start Time
MAKEDATETIME([Date],[Scheduled Start Time])

Arrival Time
MAKEDATETIME([Date],[Arrival Time])

We can then remove the Date field and then calculate how late each student was by using a datediff calculation: 

Lateness
DATEDIFF('minute',[Scheduled Start Time],[Arrival Time])

At this stage our table should look like this: 



Step 2 - Output 1

At this stage we want to split the workflow into separate branches - one for each output.

In our first output we want to calculate the average lateness of students per weekday. We can calculate this using an aggregate step where we group by Day of Week and Avg Lateness: 



We can then rank the days based on the how late the avg is: 



Then split this into minutes and seconds:

Minutes Late
FLOOR([Lateness])

Seconds Late
ROUND(([Lateness]-[Minutes Late])*60)

We are then ready to output our first table: 



Step 3 - Output 2

For the second output we want to go back to the step where we calculated the 'lateness' and create a new branch.

Within this branch we can calculate whether a student was very late or not.

Very Late?
IF [Lateness]>5 THEN 1 ELSE 0 END

Using this field we can aggregate how many classes each student has attended and also how many they have been very late for. We can group by Student ID and then sum Number of Rows and Very Late?



From here we can rename the Number of Rows field to Number of Days Present and then calculate the % of total that they were very late.

% Days Very Late
ROUND(100*[Very Late?]/[Number of Days Present],1)

Then finally we can rank our table based on the % of very late days: 



Then our 2nd output should look like this: 


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