Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (17.6k points)

enter image description here

I've been tasked to set up a Tableau worksheet of counts of data (ultimately to create percentages) where the contrived incoming data looks like the following.

id  fruit

1   apple

1   orange

1   lemon

2   apple 

2   orange

3   apple 

3   orange

4   lemon

4   orange

The worksheet needs to look something like the following:

Count of ids

2   Lemons

2   No lemons 

I've only been using Tableau for about 4 hours, so is this doable? Can anyone point me in the right direction?

The data is coming in from a SQL Server database in a format that I can control if that helps contribute towards a solution. 

closed

1 Answer

0 votes
by (47.2k points)
selected by
 
Best answer
  • LODs can be more flexible if you need to extend your solution to include more categories for the current scenario, create a calculation with below formula and create text table using COUNTD(Id)

{FIXED [Id]:IF MAX([Fruit]='lemon') THEN 'Lemon' ELSE 'No Lemon' END}

enter image description here

  • Now for the extension part, you are considering the below list where you want to count IDs with Lemon, Apple, and others. Since no double counting of Id's is allowed, categorization will follow the order. (This kind of precedence will be a headache without LODs)

enter image description here

  • Now you can change your calculation as below:

{FIXED [Id]:IF MAX([Fruit]='lemon') THEN 'Lemon' ELSEIF MAX([Fruit]='apple') THEN 'Apple' ELSE 'No Lemon or Apple' END}

  • Visualization will automatically change to include the new category. This can be extended for any number of fruits.

enter image description here

Related questions

0 votes
1 answer
asked Sep 19, 2022 in BI by Nandini V (32.9k points)
0 votes
1 answer
0 votes
1 answer
asked Dec 28, 2020 in BI by dev_sk2311 (45k points)
0 votes
1 answer

Browse Categories

...