Spatial Parameters in Tableau 2024.3
Spatial parameters in Tableau 2024.3 are a brilliant addition, but the real work is wrapping your head around the WKT format first.
- Spatial parameters require the WKT format rather than latitudes and longitudes, and an online WKT playground tool is the easiest way to generate the point, line and polygon strings you need.
- Loading highly detailed spatial objects (like all US states) into a parameter causes severe performance problems, so it's better to build a fixed list of optimised polygons that persist in the workbook without a data source.
- To attach real geometries to Superstore, add a spatial file and use a relationship matching state name to the spatial file's name field.
- Use BUFFER() with your spatial parameter and a distance to create a focal area, then use INTERSECTS() (which returns a Boolean) against the underlying geometry to filter and create a zooming effect.
- Detected geographic fields (country, region, state, city) are not true geometries; only points, lines and polygons defined in WKT count as spatial objects.
- Understanding the WKT spatial format0:34
- Finding a reliable WKT tool1:41
- Performance pitfalls and preamble3:10
- Building the base map3:56
- Creating the spatial parameter4:52
- Adding a spatial file with relationships5:38
- Building a fixed list of polygons8:11
- Creating a buffer from the parameter10:38
- Intersects calculation and filtering12:47
- Making the buffer dynamic15:30
- Wrap-up and use cases16:54
0:00Spatial parameters are now available in Tableau 24.
0:033, but in order to use this I actually had to go on a bit of a learning journey, specifically to understand what the WKT Speci special spatial format is
0:13inside a tableau, you can't use lats and longs.
0:15And so in this video, I sort of take you on that journey.
0:18I show you how the spatial parameter works and then I show you a couple of use cases.
0:22with spatial parameters that you can deploy right away.
0:25And this is a great addition to the spatial capabilities.
0:27They've been on a tear for the last four or five years.
0:30This is just yet another capability.
0:32As ever, let's get stuck in.
0:33So as I've called out, the thing about this feature is actually just the uh what I would say the the learning curve that you go on about this new spatial format, the WKT format.
0:44And
0:44The way I started that journey was actually to look at the good documentation from Tableau.
0:49You can see here I'm on the page about spatial parameters and operators, and they list it quite nicely.
0:54They talk about it up front.
0:55So if you've never come across this before
0:57You're definitely going to go on a journey a little bit to understand how to use the spatial format in the parameter.
1:02And I think the reason they landed at this is because it's the most optimal thing to put into a parameter.
1:07In order to be able to uh use it as a parameter, if that makes sense.
1:11So essentially the way it works is you go ahead and create a parameter as normal, but the WKT format itself is sort of interesting.
1:18So what I did is I went on to
1:20of course Wikipedia.
1:21I'll just zoom back out here.
1:23And um there's a really good article here and it's just basically another format.
1:26There's a lot of spatial format in in spatial analytics.
1:30And the really simple thing to actually just focus on is this, the way that these objects look like.
1:35So essentially these are the things you need to be putting into the parameter for it to work.
1:40And so then I started going on the journey.
1:42Well, how do I know what the uh WKT format for the thing I want to do looks like?
1:48And I just honestly couldn't find an easy answer.
1:50This is one of those things where if you know the topic well enough
1:53you just know the resources that will tell you this answer or you'll have the tools to give you this answer.
1:57But if you don't know this topic, if you're new, you're just trying to build something on Tableau Public.
2:01Frankly, you need a website that does it for you.
2:03So I spent 30 minutes and I found this one.
2:06This is the reliable one.
2:07And for each one, what I did is I tested their output.
2:10Put it in Tableau and for some reason all of them but this one generated exactly what Tableau needed.
2:15So I think it's maybe just, you know, the internet resources maybe not being great.
2:19I found this.
2:19And what this website does is it allows you to play around with the different spatial formats, the line, points, and polygons.
2:27In the WKT format.
2:28So as a simple example, um, you can see I've got this dot here on Los Angeles, and it's given me the point.
2:33Additionally, I can uh draw a line here by just doing this.
2:37And if as as soon as we did that, um we can get the line string for that line.
2:42Additionally, we can then say, okay, let's go ahead and draw
2:45uh this uh this shape and I think what I did there is I didn't actually complete it properly.
2:50So there I've drawn the triangle a little bit more and as you draw it out a little bit more you can see that the uh polygon here changes.
2:58So
2:58You can see why this is the preferred format for parameters.
3:01It's actually super interesting to see this format.
3:03And then of course you can yeah, I think you can draw a square as well.
3:06That also works.
3:07So um yeah, this is what I've used.
3:09And what I'm doing in this demo is I'm essentially using the points here and I'm taking them.
3:13Now the reason you want to do this is because um if you try and load a spatial element from, let's say, a data source.
3:21What you're gonna find is some of the spatial formats we've been used to generate really large polygons, really large strings in this format.
3:29And I think it caused a performance issues.
3:31I actually got stuck myself trying to figure out how to do this
3:34And I just managed to get Tableau to use up all the resources on my M3 Max laptop.
3:39It's not like a uh a small or underpowered laptop by any means, but we were just maxing out the resources.
3:44So
3:45I give that preamble because I think when you go and start building this, you might fall into those same traps.
3:49But I'm going to link to all the resources that I've shown you here so far so you can use them to ground your understanding.
3:55Okay, now we've got the context out of the way.
3:58Let's head back to Tableau and let's actually start building this.
4:00So the way I've done this is actually uh quite simple.
4:04There's a couple of things we can do.
4:06The first thing is you can just go ahead and let's just build a map.
4:09Let's just do this very, very quickly.
4:11Just double-click on city.
4:12And yes, I'm using Superstore.
4:14So many people critique me for using like not real-world data sources, but honestly, to make this video is under 15 minutes, this is all I can do because I know you know how to find Superstore.
4:23So I'm gonna leave this here.
4:25I'm gonna go ahead and drop sales on size and um I'm gonna just uh make this a little bit larger.
4:31I'm gonna do some formatting just for legibility's sake here.
4:34We're gonna go ahead and use a range, we're gonna drag this up, I'm gonna
4:38Bring that up so the big things a bit larger and the small things a little bit more obvious.
4:42And then we'll go ahead and do a white circle around these just so that it looks a bit more interesting.
4:46And then actually I'll dial that back down to that point there.
4:49I think that's a good looking map.
4:51Let's move on.
4:51Now
4:52In order to use this feature, we have to create the parameters.
4:55So let's first go ahead and create a parameter.
4:58And to do this, you'll just go ahead and do this and we'll go ahead and say spatial.
5:03I always actually recommend doing this really early on.
5:05And if you go down to the data type, you'll see there's a new option here, spatial.
5:09And there's a couple of ways you can use this parameter.
5:13First of all, you can just allow all values
5:15What this will do is it will allow you to feed in a value into this parameter.
5:20So if you're using a parameter action and you want your
5:23uh work but to feed in a wkt polygon into this then you can do that and that allows you to store these wkt strings as uh text objects inside of your
5:34a data source but then you can push them into the parameter as a way of working.
5:38Now the other thing is you can load it from a data source.
5:41So you can go ahead select the list.
5:42And that allows you to save multiple ones.
5:44I'll come to that in a second.
5:46But yes, when a workbook opens, you can say to Tableau, hey, when this workbook opens, go and load it from a spatial spatial file.
5:52Now I don't have one in superstore because
5:54Although Superstore has these geographical fields, you can see country is a geographical field here with the little globe icon, these are not real spatial objects inside of Tableau.
6:04So in order to get this to work, we're gonna have to go into the data source
6:08We're going to go and add a spatial file.
6:11And I went and downloaded a spatial file for the United States.
6:14Let's go ahead and select that.
6:16And if you drag that in, we're going to do a relationships.
6:18If you haven't done a data model before, go ahead and check this out.
6:22This is actually quite simple.
6:23All we're going to do is say that look, a state on the superstore dataset is equals to uh the name on the spatial file.
6:31And that will uh essentially do like a match with the strings, but the string on the right
6:36Also has spatial data that comes with it.
6:38So that relationships allows us to use the spatial objects in this logical table here for our orders, peoples, and returns, because it's all related.
6:47So that then means we go back into the sheet
6:50We'll just give this a little bit of time.
6:52We now have uh sort of grafted on a geometry.
6:56This is a real geometry, this is a polygon in this specific instance that can actually be used.
7:01And so if we go back to our parameter option, let's just go ahead and create that parameter again.
7:06We go back in here to spatial, we go to list, and you go when workbook opens load from.
7:11You can see the geometry is right there.
7:13Now
7:13Big warning, don't do this.
7:16Don't do this because the spatial objects I found are really detailed.
7:21And whenever I tried to do anything with these spatial objects, especially all the states in the United States, it just took way too long
7:27I've already mentioned the performance issues.
7:29This is where I stumbled across it.
7:31So based on my understanding and where we are today, if you don't have an ability to build the um
7:37What I would say the um the shape files in a more optimal way by reducing the number of points on the polygon so it's a little bit more performant
7:45Something like Altrix can do that, but if you don't have that ability, what I'd actually recommend you do is you stick with a list.
7:50And because these are parameters, you can actually invest a bit of time into building these once and then just having them available in your workbook.
7:57They're not a data source, so they can you know just persist in your workbook without needing to be updated.
8:02So that's actually quite a useful thing.
8:03And the parameters available in the entire workbook, right?
8:06It's available to every sheet, it sits outside of the data sources
8:09So that's what we're gonna do.
8:11We're not gonna load from anything else actually.
8:13We're just gonna select this fixed option and then that will allow us to add
8:17So now that we have done that, you can see why this is a little bit more complex.
8:21Let's go and let's just try and uh create some polygons.
8:25We'll choose Los Angeles.
8:26I'll sort of copy uh that.
8:28Uh I could have um uh yeah, let's just copy that
8:31Let's go back in here and what I'll do is I'll double click that paste and then I need to hit tab for some reason on Mac Apple Silicon.
8:38If I if I hit enter, it kind of clears it.
8:40And then the thing here is that when you paste the parameters, this is normal behavior, it just names it after whatever's there.
8:46But because you're using polygons here, you definitely don't want this to be what the user sees.
8:51So here what we'll say is we'll say Los Angeles.
8:56I think that will do for now.
8:57And then we can go and get another one.
8:59Now, something I haven't tried.
9:01We're going to try this in real time together.
9:03I'm going to draw a polygon.
9:05Okay, so I'm going to draw this slightly strange polygon here.
9:09And we're just gonna do this.
9:10We're gonna take the Los Angeles area, okay?
9:15And once we've got that, I'm just gonna grab all of this again.
9:19I'm going to go back to Tableau.
9:21And the nice thing about this is because this is the we previously used a point here, I can actually paste this, go to the next one, and now I've got a point and a polygon in the same parameter.
9:31This is quite handy because you can actually mix between different uh spatial types.
9:35I don't know if it will work, I don't know if it will complain and say, hey, I'm mixing types when I start to do calculations.
9:40If it does, we'll just change it back to a point.
9:42But I'm going to leave that there for the purpose of this video.
9:45So now we have two points.
9:46So we can go ahead and click OK.
9:48Now we're pretty much good to go.
9:49I did something very bad.
9:50I did not name my spatial parameter.
9:53Let's call that spatial right away.
9:55And now that we've done that, let's go ahead and hit OK.
9:59So we've got spatial.
10:00We're going to actually show this parameter here so you can see it there.
10:03Los Angeles.
10:04You don't have a drop-down option.
10:06I don't know why that is.
10:07I don't know why we can just have a drop-down selection.
10:09So I'll choose a single value list.
10:11Um and again I did not name in my uh Los Andres region elements.
10:16Gosh, you can tell I have really bad habits that have just stuck with me for a long time.
10:20So
10:21Let's delete that awfully long name.
10:23I should have done it when I actually created it.
10:25Um so if I just do that and just say I don't know uh LA
10:29area.
10:29So we've got Los Angeles the place and then we've got the LA area and we can just use that and you can see these two working quite nicely.
10:37So
10:37The next thing I need to do is to create a buffer.
10:40Now you're probably wondering why on earth do I need to create a buffer?
10:43Well, we want the buffer to be driven by this parameter.
10:46And so if you've been watching the videos over the last few years, you'll know that all of these spatial tricks that we've been
10:51Sort of teaching you all along the way now come into effect here because we need to bring them together.
10:56So the first thing is the buffer function.
10:58What the buffer function does is essentially create a buffer around a spatial object.
11:03In this case, we're going to use
11:04our spatial parameter.
11:05You can see that it comes up there as I start to type.
11:08And then we're going to need to say the number.
11:10So we'll just say let's draw a hundred mile area.
11:13And the way we do miles is we just say miles in there like that
11:17So that is now valid.
11:18We'll call this the buffer.
11:20Okay, and so we'll just say apply and hit okay.
11:23There is our buffer.
11:24Uh if we actually want to visualize that, we can go ahead and put it on a map layer, a nice new feature
11:29When we do that, let's just make it red so you can more easily see it here in this tutorial.
11:33So now we're on the Los Angeles area and if I just go and click on LA, um oh no, that kind of breaks.
11:39What does it say?
11:40Um the axis has one null value.
11:42Let's see long the axis has one null value.
11:44Oh, why is that breaking?
11:45I d I think it does not like the polygon.
11:47So let's go back.
11:48Let's go back.
11:49I think I was being too optimistic.
11:51Let's choose a radically different um uh place.
11:54Let's go to New York.
11:55Let's choose New York as an area.
11:57So let's go ahead and put this here.
11:59We'll go ahead and grab that and we'll replace that um
12:03Item that we got wrong, let's go ahead and select this and go and remove the selected version.
12:10That's a quick way of doing that.
12:11Paste that in, and then here we can say hey, this should be NYC.
12:16And hit apply and hit okay.
12:18Good.
12:18So now we've got Los Angeles.
12:19Switch over to New York.
12:21It works.
12:21It didn't like the multi-polygon.
12:23Fine.
12:23We tried, it didn't work.
12:24But now you can see this is happening.
12:26Now, the reason I want to use this parameter is actually to switch between these to almost create a zooming effect with this parameter
12:32So you've got this nice highlighter, which is great from an analytics uh perspective.
12:36In fact, this is already working, it's already doing what we want.
12:38But to really get to sort of that
12:40nice UX that you typically use parameters and uh sets for whatever you want to use them for.
12:45Um we're gonna go one step further.
12:47So to go one step further we're gonna go ahead and create a calculation.
12:51And this one I always get confused.
12:52So there's a couple of spatial functions.
12:55So we go to the spatial area and we select intersects
12:58Intersection returns a polygon, intersex returns a Boolean.
13:02We want the Boolean because we want to use this as a filter.
13:04So if we double click intersex and we say that look, hey, our buffer.
13:09um needs to intersect with our spatial parameter.
13:14So let's say this is what it is.
13:16And so what basically what we're doing
13:18is we're saying anytime these two intersect, um keep that as true in the filter space.
13:23And of course they're going to match because they're basically being driven by the same thing.
13:26The buffer has a spatial parameter and the spatial parameter is changing.
13:29So
13:30It's it acts like moving our thing.
13:32We're also moving the buffer function at the same time, so it kind of works.
13:35So we'll call this intersection Boolean.
13:40We'll hit apply, hit okay.
13:42Now we can take that into the filters and we'll just keep true.
13:46Of course, it always works true.
13:47So what I should really do here, if I just think about this, let me just think about this for one second.
13:52I mean I think it's fine.
13:53I think we could just keep it like that.
13:55And if we just Okay, this is not doing what I expected it to do.
13:59I think I've written something just slightly wrong.
14:01So what have I done wrong here?
14:03So what I
14:04I think I think what I needed to have done is instead of doing the buffer, I should have done the geometry.
14:13from the spatial file that we've got attached, if that makes sense, to make sure that those overlap.
14:19So let me just hit apply and see how that changes the viz.
14:24You can see it's thinking about it in the background
14:26There we go, that's done what I did.
14:28So in a funny sort of way, for the zooming effect to work, we needed to use the spatial object.
14:35Um the the
14:37The the reason that true was always true is because visually speaking, the uh spatial parameter was always actually overlapping with
14:46um itself if that makes sense.
14:47That's essentially what I put into the formula.
14:49Whereas this, because the um uh let's say the uh region
14:56The spatial objects that drive the states, which is what I'm using as my spatial object, overlap with the buffer.
15:03It's zooming into the buffer because it's just trying to show us this.
15:06uh point which that is true if that makes sense.
15:09So um if I actually go to edit this you'll see that I do get a true and a false.
15:13I can actually focus on the false if I wanted to.
15:15But then now that we've got that zooming effect you can see we can go over to Los Angeles.
15:21And it switches over.
15:23So this is actually quite nice because you can create a nice focal point.
15:26Maybe you want to zoom in on salespeople.
15:28You can play around with this buffer.
15:30You can play around with lots of different
15:31uh elements of this.
15:32If we if we increase the size of the buffer, you could actually even um if you know if we're being uh really s really smart we could say hey uh can you create me another uh buffer parameter right uh we can say okay
15:44And then instead of using that item, uh sorry, not that one, let's go to our buffer itself.
15:50And instead of using that, let's actually uh uh say that we can change this
15:57With our buffer parameter.
15:59So we can just go, hey, go use buffer.
16:01So two parameters being driven there and say okay.
16:05And now this is going to break because we've made it a very, very tiny one mile radius.
16:10You can't almost see it.
16:11But if we uh show this parameter and then we say, okay, let's make it 200 so it was larger than before.
16:17then um this is working nicely.
16:19So we can create something way more dynamic, which is kind of really really nice.
16:23We're using the spatial parameter to be able to drive this behavior behind the scenes.
16:28and then we can change uh sort of uh what we're focusing on as well, which is which is really nice, I I think.
16:33And you could even, at least with this um value, you could even go um I know you can't use a slider.
16:39I guess you can't use a slider in this specific sense.
16:41Um I
16:42Sometimes I get so confused why you can't do certain things.
16:45For example, here, why can't I have a drop-down and here, why can't I have the slider that I can see there?
16:51Why would I have a slider on and text values but not have a
16:54a freaking slider here anyway doesn't matter that's tableau so that's the spatial parameter i think it takes a little bit of sort of getting around in terms of thinking through your use case
17:05You need spatial objects for this to work really, really well.
17:08Um, I'll just call out that when you have uh things like country, region, state, city, these are detected spatial elements.
17:15So Tableau maps onto them geographic globes, but they're not in fact
17:19geometries.
17:19Geometries have to be things like lines and polygons.
17:22Again, if we go back to our um well-known uh text uh page here, points, line, string, polygons, multi-point, all of these are actual things.
17:32And so they have
17:33ways of being defined in this WKT format, which I think is actually quite nice.
17:37You have the ability to be quite specific about the different ways you specify that.
17:41But
17:42Nonetheless, that is pretty much the spatial parameter.
17:46I think it's going to take a little bit of getting used to, but there are some fantastic use cases if you can bring together all the mechanics that we've had over the last four years with spatial capabilities
17:55Bring it together with this new spatial parameter.
17:58And now you're talking.
17:59As ever, thanks for watching and I'll see you in the next one.
In this video, I dive into the new spatial parameters feature in Tableau 24.3. Join me on a learning journey as I explore the WKT (Well-Known Text) format, which is essential for using spatial parameters in Tableau. I’ll guide you through the process of creating and using spatial parameters, and demonstrate a couple of practical use cases that you can implement right away. This feature is a fantastic addition to Tableau’s spatial capabilities, which have been evolving rapidly over the past few years. I’ll also share some tips and resources to help you get started. Let’s get stuck in!
Timestamps 0:00 Intro 0:49 Context 4:00 How they work 8:51 Map focus use case 15:24 Final tweaks and Thoughts