6 Replies Latest reply on Nov 21, 2016 6:09 PM by Duncan Berg

# Help colouring hexes on a shot chart

Apologies for any problems with this post...first time asking for help. Not great with the technical side (mostly been Google searches combined with trial and error to this point), so please bear with me.

I am creating basketball shot charts with hexes and then trying to colour the hexes by field goal percentage against the league average. I have asked some of the creators of other great interactive shot charts around the Internet, but I can't find anyone using Tableau, so the question gets transferred to Tableau users.

I'm really happy with what I have done to this point. The sizes and positioning of everything is fine, but the colouring of the hexes isn't coming out right.

The table shows that the data is grouped according to areas on the floor. This is created using a calculated field based on x,y data. The values in the table are working. So, for the Restricted Area (circle about three hexes in radius from the basket) the league average is 61.8%. I want all the hexes in that area to compare to the league average and the difference will be displayed by the colour range. At the moment, each hex is comparing its percentage to the league average. The red hexes are comparing their lower FG% to the league average of 61.8% for the entire zone, while closer to the hoop, their percentage is higher than 61.8% and showing green. You can see when the group is the whole zone (in the table), things are calculating correctly, but as soon as the zone is divided into smaller subgroups (the hexes), my comparison breaks down.

I have a FIXED LOD calculating the league average for each zone - working great - and I have tried an INCLUDE LOD for the zone FG%.

Zone FG% - Should calculate FG% for each zone:

100 * {INCLUDE [zone]: [shots made]} / {INCLUDE [zone]: [shots attempted]}

League FG% - Should calculate the league average FG% for the zones (and does):

100 * { FIXED [Zone]: [shots made]} / { FIXED [Zone]: [shots attempted]}

League FG% is then subtracted from Zone FG% to provide FG% Diff shown in the table above.

But because the zones are broken down further into hexes, it doesn't matter whether I do INCLUDE or just a plain SUM and gives the FG% for the data within the hex bin. I'm sure that I don't have the right combination between the two calculated field above. I'm sure the INCLUDE is not being used correctly and it is more the inherent grouping of each table/chart that is producing the FG% values. I just don't understand the technical side (particularly hierarchies of calculations) well enough yet. My attempts have come up empty for a week, so it's time to seek help.

How can I calculate the combined FG% of the hexes within a zone and have the same colour display across these hexes. I guess I want the 12 zones as large bins and then also have the smaller hex bins inside each zone. I need to display the FG% difference to the large bin, not the small bin. I guess it would be like sizing cities by number of sales and colouring them by comparing state average to national averages.

If anyone is able to decipher this, any help would be appreciated. If I need to include anything else, let me know (can I provide a link to the Tableau Public workbook instead of attaching here?)

Thanks.

Duncan Berg

• ###### 1. Re: Help colouring hexes on a shot chart

Is there anyway you can post a TWBX here so that we can play with the data itself? I don't think this will be solvable without looking at the workbook and the data. If you can post, it would be great if you could add notes as to which numbers exactly you would expect to see in the Restricted Area zone so that we have something to work towards. I'm not sure I fully understand the issue from the screenshots above but I think with the workbook I could try and help out.

Dan

• ###### 2. Re: Help colouring hexes on a shot chart

I think I've managed to attach the TWBX file.

• ###### 3. Re: Help colouring hexes on a shot chart

What I'm looking for is that each hex in a particular zone all have the same value for FG% difference. The values for FG% difference can be seen in the table.

Since all the data is being displayed initially, each hex in the zone should display the same colour. You can see the Right Corner 2 data above. Each hex currently compares it's FG% to the League FG% for that particular zone of 36.8%. Whereas I want the whole group of hexes shown to work together like the data in the left side of the table is doing. I want to be able to hover over the hexes displayed above and have 485/1317 be the calculation.

As the data is filtered for different teams and players, I want the FG% for each zone to compare with the fixed League FG%. Everything is working fine in the table and the charts except the hexes compare individually to the League FG% for that zone rather than as an entire group as is done correctly in the table.

So far it's been above my level of knowledge to group the hex bins, so any help would be appreciated.

Duncan.

• ###### 4. Re: Help colouring hexes on a shot chart

Duncan - so for this example -

Do you want the difference to be the Hex specific value - 42.86% FG% - the league avg for every shot from Right Corner 2 - which is 36.8% for a difference of 6.03% ?   You have that in the tooltip though so I think you want something different.  Maybe telling us one example with the number desired?

Patrick

• ###### 5. Re: Help colouring hexes on a shot chart

Hi Patrick,

I would like hex to display the FG% difference for the entire zone, which would be 0.0.

I would like the hexes to ignore their own localised bin value for FG% difference and reflect the value for the whole zone.

Hopefully it's possible.

Thanks,
Duncan.

• ###### 6. Re: Help colouring hexes on a shot chart

The tooptip is mainly for me to play with at the moment.

In the end it will show the values that are reflected in the table.

Ideally...