The first challenge of the famous, or rather infamous, dashboard week! We were assigned to find an API to connect and draw information from and then put it in an insightful dashboard. For this challenge I have decided to utilise an NBA API to create a comparison between all-time greats Kobe Bryant (RIP) and Michael Jordan.
I first started by trying to find a quick and easy access API to connect and gather information from before 11AM. Then I would start time-boxing through blogging each part. My plan is to have all the Alteryx and Data Preparation including the creation of a visual basketball shot-chart done by 3pm and then quickly finish a simple dashboard and rest of the blogging.
Extracting Information and Data Prep
I had to first find the parameters for Kobe and Jordan for their IDs. This required a search parameter based on their name.
The code appeared to have required a get function but Alteryx does this automatically. It also required the host and key as separate headers, which is a bit different from a lot of other APIs.
The headers names must be exact or the query will fail.
Blockage 2: Has a limit of querying 100 records at once.
There is a function that allows you to search and return multiple, but it doesn’t work for the number of pages. To do this we can simply use a batch macro that pulls through all the required pages.
Also, when a batch macro detects a number, it automatically determines it as an integer regardless of whether you set it as a string or not beforehand. This will cause type-mismatches but can be solved by first putting that number into another formula and setting it to a string.
Blockage 3: Determine which batches are which.
Because the batches come altogether, you can’t group them using the header or only 100 records appear with only the rest concatenated inside. Therefore I had to use a Multi-Row to create a separate row ID then group by those IDs.
Spatial for Basketball
A similar API process was used to query out basketball shot-chart data to help add more visual analysis. The data was then left-joined to the previous dataset.
Building the shot-chart:
This process took some time so I’ll just briefly skim through.
First I noticed that the x and y coordinates seemed to have a bit of mismatch from the actual representation.
When we put this onto the background map, we see that indeed some fixing is required.
We can fix the locations by setting up the following axis for the x and y.
Blockage 4: Points are too spread out.
Since we are analysing by individual players and seasons, the presented points are way too spread out. This results in most points having only around a few shot to one shot. To solve this, I used a hex-bin to group close-by points together. Here Bin Size is just a ranged parameter with a current value of 0.2.
Then after readjusting the map again and selecting the new coordinates, I tested the bin threshold for Kobe and Jordan. The optimal threshold visually seemed to be 0.2.
After adding in size for attempted shots and colour for made shots, I realised that I barely had anytime to write my blog left.
Blockage 5: Time
It is currently 12AM and I will definitely consider a better time-boxed project next time. The rest of the dashboard is just very typical Tableau and so I won’t elaborate further.
(Header is a little janky cause Tableau Public. Reminder to self: always use Images for Headers).