3
votes

I am very new to Tableau, and I am trying to create a Scatterplot which can be viewed at different levels within the Hierarchy on the same Dashboard. For example, suppose I have employee counts, company counts and population density and I have this information by city, and these cities are in certain states.

I would like to be able to view the ratio # Employees/# Companies along the x-axis, population density along the y-axis, and I would like the ability to have each city shown as a separate bubble, and be able to, say, filter on Maryland, and show only the cities within for Maryland. This is all very straightforward using two quickfilters.

I'd also like to be able to somehow allow the user to specify that they want to see the bubbles at the State level, and once they select that option, it no longer shows the bubbles by city, it has aggregated those bubbles and is showing them by State. How do I do this?

Thanks!

2

2 Answers

2
votes

Well, that is very easy to do when you are editing the view (just drag the field to detail and use the collapse option), but not so easy to provide this option to users.

I can think of a little hack. Create a parameter named [Level]. Make it a list of values, like 'City' and 'State'.

Now create a calculated field [Level of detail]:

CASE [Level]
WHEN 'City' THEN [City]
WHEN 'State' THEN [State]
END

I'm assuming your city and state fields are named [City] and [State].

Now drag this [Level of detail] field to details, and let the user choose the parameter. When he chooses 'State', it should aggregate on State level. Same for City.

0
votes

One approach is to create a hierarchy out of the City and State fields.

To do that, in the data pane on the left, drag the City field and drop on top of the State field. You should get prompted for a hierarchy name of your choice, and then see the two fields grouped together in the data pane underneath the hierarchy name. State should be above City, but if not, just drag into the right order.

Now drag state to the detail shelf and build your view. Note there is a + sign to the left of State on marks card. You can press the + to expand the hierarchy and drill down to the City level. Then you can hit - to roll back up.

Custom hierarchies work for all kinds of discrete dimensions, not just those with geospatial roles.