I spent part of the Easter long weekend getting into workout Wednesday challenges. One in particular, #WOW2020 Week 34 was tricky (lots of calculated fields!) but very worthwhile and a great way to cement what we’re learning at the Data School. Here are some of the takeaways I took from the challenge.

MAKEPOINT([Latitude], [Longitude])

There are a few instances in this challenge where you’ll have to create a calculated field and use the MAKEPOINT function for creating a ‘Crime Point’ and for creating the locations for Buckingham Palace and St Paul’s Cathedral. By taking the latitude and longitude, you can create a spatial point to make your distance calculations down the track. We’ve used the MAKEPOINT function previously at the Data School, but it was nice to come back to it and use it in a straightforward WOW.

Location parameter

This WOW requires you to create a location parameter using a string data type to switch between St Paul’s Cathedral and Buckingham Palace. Admittedly, this step took quite a bit longer than it should have as I overcomplicated it before realising it was as simple as making a list of two allowable values.

Case

CASE [Parameters].[Location]
WHEN ‘Buckingham Palace’ THEN [Buckingham palace]
ELSE [St Paul’s Cathedral] END

I used a basic CASE function to create a location switch – a way to toggle between locations on the map to see what number of crimes were committed around these areas.

DISTANCE([Location switch],[Crime point],’mi’) / DISTANCE([Location switch],[Crime point], ‘m’)

Now that you’ve got your crime point and your location switch, using latitude and longitude, you’ll need to create two other calculated fields to give you your distance in miles and metres. Above, we’re saying give me the distance between A and B in miles or metres.

Miles parameter

Different from your location parameter, you’ll need to create a miles parameter using an Integer data type to allow the user to change the distance they’ve selected using a range of values. That way, you’ll be able to see what number of crimes are committed within 1 mile of St Paul’s Cathedral, or 8!

Tooltips

If you check out Lorna Brown’s original on Tableau public, you’ll see there’s a line chart within the tooltips, as well as some other key information. Formatting this took some time to work out, but mine has ended up looking something like this:

<LSOA name>
Number of Crimes: <CNT(Crime ID)>
<Sheet name=”Sheet 6″ maxwidth=”200″ maxheight=”200″ filter=”<LSOA name>”

I found this challenge really worthwhile and I highly recommend trying it out! Here’s a screenshot of my map:

Here’s my attempt: https://public.tableau.com/app/profile/emma4516/viz/WOW2020Week34CanyoushowallthecrimeswithinXmilesofYpoint_16810377761010/Dashboard3

And here’s the WOW original: https://public.tableau.com/app/profile/lorna.eden/viz/WOW2020Week34CanyoushowallthecrimeswithinXmilesofYpoint/WOW2020Week34

 

 

The Data School
Author: The Data School