Lynn
Lynn

Reputation: 4388

Display percent by category in tableau

I have a dataset in tableau where I would like to show the percent of each category.

Data

free    use type    date
10      5   A1      1/1/2021
20      1   A1      1/1/2021
40      2   B2      1/1/2021
60      3   B2      1/1/2021

Desired

   type      %

   A1      50%
   B2      50%

Doing

enter image description here

SUM( [type] ) / SUM( [type] )

However, because 'type' is a string, the calculation is not successful. Is there a way to showcase a groupby and to display the percent? Any suggestion is appreciated

Upvotes: 2

Views: 2522

Answers (2)

G Hart
G Hart

Reputation: 546

Assuming that you are trying to get the percent of rows per "type", you can

  1. Drag your "Book1.csv (Count)" to your Text marks card
  2. From the marks card, click Percent of Total

Alternatively you can create a calculated field containing COUNT([Book1.csv]) / TOTAL(COUNT([Book1.csv]))

Example output from Superstore Dataset

Upvotes: 3

CoderRambo
CoderRambo

Reputation: 402

Please try using

count([type])/running_sum(count([type]))

as a calculated field and let me know if this helps.

Upvotes: -1

Related Questions