Count the number of instances of values across multiple dimensions in Tableau

Blake picture Blake · Aug 3, 2016 · Viewed 11k times · Source

I'm currently looking to count the number of instances a values shared across multiple dimensions. For example, say I have the following set of data:

enter image description here

And I want to return something like:

enter image description here

But ideally in the form of a bar graph. I want to keep the names associated with the data, so I can filter lets say by all "Bobs" or all "Hannahs".

Does anyone have any advice on how to do this in Tableau?

Answer

Nick picture Nick · Aug 3, 2016

Here are a couple of ways you may be able to do this.

1) Create a calculated field for each food type. This is a bit cumbersome and you would need to add new ones for any new foods added. You calculations would look like this:

Hamburgers: SUM(IF [Food1] = 'Hamburgers' OR [Food2] = 'Hamburgers' THEN 1 END)

Then you would make use of the Measure Names and Measure Values built-in fields.

enter image description here


2) You can normalize your data. If you are referencing a Excel or Text file, you can do this right in Tableau. Simply go to the Data Source tab, select the Food fields, and choose to Pivot them:

enter image description here

Goes to:

enter image description here

Now you can do:

enter image description here


Finally, both results support creating a bar chart:

enter image description here