3 Replies Latest reply on Jan 23, 2018 10:39 PM by Karthikeyan Vivekananthan

# Calculated Field - Basic - HELP PLEASE!!

Hi, I am new to tableau, so this is probably a very basic question.  I am trying to create a new field from a YES/NO question. I build an expression, but it is showing me some errors.

Beer drinkers

 Role: Continuous Measure Type: Calculated Field Default aggregation: Sum Status: Invalid

Formula

IF[2 1. (Beer) In the past seven days, how many servings of the following alcohol beverages did you drink, both at home and away f]="YES" THEN "DRINKER" ELSE "NON-DRINKER" END

• ###### 1. Re: Calculated Field - Basic - HELP PLEASE!!

Is it possible to share your workbook ?

• ###### 2. Re: Calculated Field - Basic - HELP PLEASE!!

IF MAX([2 1. (Beer) In the past seven days, how many servings of the following alcohol beverages did you drink, both at home and away f])="YES" THEN "DRINKER" ELSE "NON-DRINKER" END

• ###### 3. Re: Calculated Field - Basic - HELP PLEASE!!

Hi Monica Erazo,

I believe you are using both Aggregated measure field and Dimensional fields in your calculation. This might caused you 'Cannot mix aggregate and non aggregate arguments with this function.

To resolve this, include ATTR function on all Dimensional fields used in that calculation.

I mocked up some data, created a calculated field based on your requirement and calculated field will detect Drinker and Non-Drinker values.

Drinker/Non Drinker

IF ( ATTR([Drink beer in Past Seven Days]) = 'Y'

AND ATTR([Both at Home and away])  = 'Yes'

AND SUM([Number of Servings]) > 0 )

THEN 'DRINKER'

ELSE 'NON-DRINKER'

END

Please find attached a sample screenshot. Also attaching sample workbook created in Tableau 10.4.1, to open this file, use Tableau 10.4.1 or later versions.

If you are error is different, let me know, I will help.

If the above solution satisfy your need, please change the status of this ticket to answered and close.

Thanks,

Karthik