I have a similar problem. Has anyone figured out a way to make this work without trying to put the county data into the data set?
I'm 99% sure that you can't do this. The problem is that Tableau needs to know the geographic role associated with any fields used for geocoding, and that can't be set dynamically. So although you have a calculated field which can have a value of State, County or Zip driven from a parameter, that doesn't give you any way of changing the geographic role.
The only way that I know of dynamically changing the level of detail for geocoding is to define the fields with the different geographic roles in a hierarchy, following the true geographic hierarchy (Country->State->County, say). You can then expand and contract the hierarchy, which displays more or less detail. That only works if you have the individual view open, though - I don't think you can expand and contract the hierarchy from a dashboard. It's also no use to you, because Zip is at the same level as State in the hierarchy (i.e Zips are across the whole country, not broken down by State and County).
It's an ingenious trick, although I would definitely call it a work-around rather than a solution to the problem. This is something I would love to see Tableau solve in the next release. I often want to be able to have the capability to let end users drill up or down in a geographic hierarchy.
Joe's trick seems to work with maps in workbooks, but when I publish views to the server it no longer works. If anyone knows of any tricks to make it work on the server, I would absolutely love to hear about it.
Hope that helps.
Hi Allan, not quite what I'm looking for. I actually have virtual parameters set up already. What what I've found is you cannot do the drilldown because you cannot have both zip code and County in the detail card because they aren't necessarily inclusive. Instead what I had to do was put the state and county on one tab and the zip codes on a different tab. What I would have preferred to do was have a parameter that allowed you to go from State --> County --> Zip (see the Level parameter in the link below):
Frank the reason you can't get what you want is because ZIP Codes can and do cross both county and state lines. (As far as I know they don't cross country boundaries, at least not in the US.) Since ZIPs aren't contained within these units an accurate hierarchy can't be produced. So instead Tableau uses these two hierarchies:
Country / ZIP Code
Country / State / County / City
If it were any other way T wouldn't know what to do with multi-county (many) or multi-state (rarer) ZIP codes. This doesn't solve your problem, but at least you now know there's a reason for it.
EDIT: Actually it may be 3 hierarchies:
Country / ZIP Code
Country / State / City
Country / State / County
Because cities can cross several counties, but I didn't test this, so buyer beware.
Correct, this doesn't use the Tableau drill-down method, or the level of detail shelf; because it allows for custom hierarchies. However, that method would allow you to do what you ask, you just need to use ZIP as your lowest level "dummy" hierarchy. That demo only does Country-> State -> County, all you would need to do is to set up ZIP as the lowest level. The rationale behind this method is that as Shawn states, ZIPs can cross multiple boundaries (state, county etc) and therefore don't lend themselves to a logical hierarchy.
One benefit is that you can use the "correct" ZIPs rather than Tableau ones, and you can also add in other country Zips, as long as you understand how the data has been shaped.
I'm sorry I can't add the level in for you - I just don't have time...but if you get the jist of the CF's that drive it, then I'm sure it could help.
I can say with 90% certainty that I tried the method you linked to 7 months ago when I was walking on this with no success given what I was trying to accomplish. Shawn hit the nail on the head as to what the problem is.
That said, I do appreciate the feedback. To me the issue has come and gone ;-).
Not a problem, you're welcome. Just to say, there's more than one way of skinning a cat!