4 Replies Latest reply on Jun 16, 2016 1:34 PM by Tejal Narkar

Hi Guys,

I am trying to get a headcount of total people working last year. I want it to be dynamic and so I am trying to replace 2015 with MAX(YEAR([Year]))-1.

COUNTD(IF YEAR([Year])=2015 THEN ([Employee_Perner]) END)

I am getting below errors on doing so:

Cannot mix aggregate and non aggregate arguments with this function

Cannot mix aggregate and non aggregate comparisions or reuslts in IF expression

I am new with tableau and I would really appreciate your help.

Regards,

Tejal

• ###### 1. Re: Calculating last years(n-1) Headcount

Put ATTR around your Employee_Perner field: THEN ATTR([Employee Perner])

• ###### 2. Re: Calculating last years(n-1) Headcount

HI Tina,

Thank you for helping me. I tried using below formula:

COUNTD(IF YEAR([Year])=MAX(YEAR([Year]))-1 THEN ATTR([Employee_Perner]) END)

It is still giving me below errors.

Cannot mix aggregate and non aggregate arguments with this function

Argument to countd(an aggregate function) is already an aggregation and cannot be further aggregated.

Regards,

Tejal Narkar

• ###### 3. Re: Calculating last years(n-1) Headcount

COUNTD(IF YEAR([Year])={MAX(YEAR([Year]))-1} THEN [Employee_Perner] END)

1 of 1 people found this helpful
• ###### 4. Re: Calculating last years(n-1) Headcount

Thank you Derrick! That worked for me