如何根据 Tableau 中列的不同值计算饼图?

How to have pie chart count based on distinct values of a column in Tableau?

在数据库中 table 我有这样的东西:

RatingID, StudentID, Sport, Rating
1, 1,     Tennis, 2
2, 1,     Tennis, 5
3, 2,     Basketball, 2
4, 2,     Basketball, 5
5, 3,     Basketball, 2

我想要一个饼图来计算参加每项运动的人数。 目前,我使用 "Sport" 得到一个饼图,上面写着:

BasketBall: 3
Tennis: 2

当我尝试做一个 Distinct(SPORT) 时,它说两者都是 1。 我想要做的是能够对 StudentID 进行区分,这样饼图显示:

Tennis: 1
Basketball: 2

我该怎么做?可能吗?

您需要在 StudentID 而不是 Sport 上执行 COUNTD。您将在色卡和标签卡中使用 Sport

像这样: