error on aggregate and non aggregate values

0 votes

While creating the following calculated field I am getting an error on aggregate and non aggregate values.

 if (COUNTD([Category])=1 then [Sub-Category]
else [Category] END

Note: I am using the super store data-set. So when a user selects a filter in the quick filter for category, I was expecting that the countd becomes one and shows sub category as rows in the table instead of category.

Apr 17, 2018 in Tableau by ghost
• 1,790 points
1,068 views

1 answer to this question.

0 votes

Create a calculated field that outputs a column to be used a the filter to select the sheet.

  1. Create the following calculated field:
{ FIXED : if COUNTD([Category]) = 1 
then 'Sub Category' elseif countd([Category]) > 1
then 'Category' END}
  1. Create two worksheets first one broken down by category and the next by sub category.
  2. Add the Category filter to both worksheets and set to a context filter.
  3. Drag the calculated field column to the filter pane. For the Category worksheet select the filter to Category and do the same for the sub category worksheet.
  4. Finally drag both the worksheets into a dashboard and format them appropriately.
answered Apr 17, 2018 by ffdfd
• 5,550 points

Related Questions In Tableau

0 votes
1 answer

Error - Aggregate and on-aggregate cannot be combined.

Hi Ritu, This happens when you are comparing ...READ MORE

answered May 23, 2019 in Tableau by anonymous
• 33,030 points
2,845 views
0 votes
0 answers

Cannot use aggregate and non-aggregate fields in the if statement

Hi. I cannot use aggregate and non-aggregate ...READ MORE

Oct 7, 2019 in Tableau by ch
• 3,450 points
747 views
0 votes
1 answer

how to get the count of non zero values in a row

In first part you should solve the ...READ MORE

answered Apr 4, 2018 in Tableau by Atul
• 10,240 points
3,098 views
0 votes
1 answer

Rank measure values and show percentage of measures in Tableau

Hi Sindhu, 1. First create a table with ...READ MORE

answered Mar 8, 2019 in Tableau by Cherukuri
• 33,030 points
4,362 views
0 votes
1 answer

How to color code cells of a column based on the text value in Tableau

You can use the following steps to ...READ MORE

answered Mar 27, 2018 in Tableau by Atul
• 10,240 points
9,903 views
+2 votes
1 answer
0 votes
1 answer

Calculated filed with if-then

Below is the required code:  IF (NOT ISNULL([test2])) ...READ MORE

answered Mar 27, 2018 in Tableau by Atul
• 10,240 points
1,601 views
+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to calculate profit when cost and revenue are in same column?

You can create the following calculated fields: Profit: SUM(IIF([account_category] ...READ MORE

answered Apr 10, 2018 in Tableau by ffdfd
• 5,550 points
1,191 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP