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
83 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 Atul
• 5,530 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 22 in Tableau by anonymous
• 17,870 points
30 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
106 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 in Tableau by Cherukuri
• 17,870 points
108 views
0 votes
1 answer

How to aggregate and count the occurrence of TRUE and FALSE?

Hi, you can do any of below ...READ MORE

answered Mar 12 in Tableau by Cherukuri
• 17,870 points
64 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
1,360 views
+1 vote
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
50 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 Atul
• 5,530 points
55 views