Posts

2021: Week 27 NBA Draft Lottery calculator

Image
 Challenge by: Carl Allchin Every now and then at Preppin' HQ when we are not busy running Chin & Beard Suds Co or Prep Air, talking about Jenny's obsession with Pokemon, we cook up a fiendish challenge. Occasionally those challenges make it into the weekly challenge. This is one of those times. Good luck! Challenge We want you to calculate the results of the NBA draft lottery for 2021 (yes the lottery actually happened on 22nd June but I only thought of the challenge on that day and Jenny had some Pokemon challenges already booked in). The flow should be able to re-run to recalculate the results as if the lottery is done again with each run.  The lottery gives teams the chance to land the best picks in the NBA draft. The NBA draft is where teams take it in turns to allocate the best young international and college players.  The lottery odds are based on where you finish the season. The team with the worst record of wins and loses gets the best chance to earn the firs...

2021: Week 26 - Solution

Image
  Solution by Tom Prowse and you can download the workflow here .  This week we looked at how to create rolling/moving calculations in Tableau Prep rather than when trying to calculate these when visualising the data. We looked at Prep Air destinations and what revenue we had made on a rolling week basis. Step 1 - Start & End Dates First we need to setup our data set so that we have 7 rows per date, or in other words, a row for each of the days that we are going to be averaging. Therefore, we need to calculate the 3 days before and after each of our dates with the following calculations:  End of Week DATE(DATEADD('day',3,[Date])) Start of Week DATE(DATEADD('day',-3,[Date])) We now have three date columns for the start, middle and end of the weeks.  Now we have the range of dates that we want to look across, we need to fill in the remain rows between the start and end dates. To do this we can make use of the >= & <= join conditions that Tableau Prep will...

2021: Week 26 Rolling Weekly Revenue

Image
Challenge by: Carl Allchin For any analyst, you are likely to get asked to use some complex calculations. For me, rolling or moving calculations are one that I've always preferred to do in the data preparation step rather than when trying to visualise the data if possible. It's saved me from some mistakes!  This week's challenge is looking at creating moving calculations. By this let's use the example below, where on 5th January (yes British date format), if we wanted to understand a rolling week's values, you can include 3 days before the 5th (ie the 2nd, 3rd and 4th) as well as 3 days after the 5th (ie the 6th, 7th and 8th).  Clearly you need to define what your rolling period should include or not. A rolling week could look backwards for 6 days inclusive of the current date or 7 days if you don't use the current date. You could look the same period forward but ultimately you have to articulate what you are covering to your audience. The nature of the data mig...

2021: Week 25 - Solution

Image
Solution by Tom Prowse and you can download the workflow here .  This week's challenge was a bit of a big one! Jenny took the inspiration from a YouTube video about how to categorise the least favourite Pokémon... and thought it would make a great Preppin' Data challenge. Let's look how to solve it.  Step 1 - Table Clean Up The first daunting part of this challenge is all of the different inputs. We have 9 in total so that's lots of different tables that we'll need to clean and combine to make our final output.  Gen 1 First we'll start by bringing in the Gen 1 table and then removing any null values and keeping only the '#' and 'Name' fields so the table looks like this:  Evolution Group Next we want to focus on the Evolution Group table, where we want to convert the '#' field to a number. We can't just change the data type as there are some leading spaces, therefore we can use the 'Trim' function to remove these, and then cha...

2021: Week 25 - The Worst Pokémon

Image
Challenge By: Jenny Martin Often our stakeholders can have very niche knowledge and their requests may baffle us. Luckily, as data preppers we have the tools to tackle any dataset, no matter how bizarre. Yes, Carl and Tom have allowed me to create another Pokémon challenge! The idea came from a  YouTube video that I stumbled across: Who Is Pokemon’s LEAST Favorite Pokémon? The logical steps applied in the video felt like they were screaming out for a Preppin' Data challenge to verify the results! But be warned, the answer to this challenge will differ from the conclusion of the video, due to differing datasets. Inputs We have multiple inputs for this challenge: Gen 1 Pokémon (from Pokémon Database ) Evolution Group (from Bulbapedia - also see Preppin' Data 2021 week 10 )  Evolutions (Bulbapedia) Mega Evolutions (Pokémon DB) Alolan Pokémon (Pokémon DB) Galarian Pokémon (Pokémon DB) Gigantamax Pokémon (from IGN ) Unattainable Pokémon in Sword & Shield (Pokémon DB) Ani...

2021: Week 24 - Solution

Image
Solution by Tom Prowse and you can download the  workflow here .  The challenge this week was to look at managing unscheduled time off at Chin & Beard Suds Co. In the challenge we are looking to analyse how many people have been off and if we have had someone off every day.  Step 1 - Build Out Dates The first part of the challenge is to build out our data set so that we cover every date listed between 1st April and 31st March. This is where the scaffold will come in useful as we can use this to fill in any dates that we might be missing in our Reasons data set.  To make sure we are starting on the correct date, we first need to find the first date across our Reasons table. We can do this by using an aggregate tool, and finding the Min Date:  We now want to join this to our scaffold. To do this we need to do a cross join so that each of the rows from table is joined with all of the rows from another. Therefore, we need to create a calculated field to do this,...