Rolando
Rolando

Reputation: 62624

How to get bar chart with distinct count based on a column in tableau?

I have the following data:

Name, Sport, Random Number
John, Tennis, 4
Jacob, Tennis, 4
Jacob, Tennis, 2
Jacob, Football, 5

I want to show a bar chart that counds up the number of People playing Sports.

X Axis: "Sport"
Y Axis: "COUNT(Number of Records)"

My current tableau is set as this:

Rows: Name
Column: SUM(Number of Records)

I want the bar graph to reflect the "Count of DISTINCT names who play the sports". My problem with the above is that the "Tennis" for example has a count of 3 instead of 2. How do I make it so that the bar shows up as 2?

Upvotes: 0

Views: 1881

Answers (1)

Alexander
Alexander

Reputation: 1967

As far as I know, you cannot get a distinct count of 2 dimensions combined, natively. However what you can do is combine two dimensions and get a distinct count of that.

Create a calculated field [NameSport] with [name] + [sport] as the formula. Then drop it on column and use COUNTD(NameSport).

That should do the trick.

Upvotes: 0

Related Questions