I have a tableau data grid that I need to count distinct records. If the status is Complete distinct count the RecordID IF [Status] = "COMPLETE" THEN COUNTD([Survey ID]) ELSE 0 END)
, but I am getting an error "Cannot mix aggregate and non-aggregate comparisons or results in IF expression". Any ideas?
Asked
Active
Viewed 1.8k times
6

Arsee
- 651
- 2
- 11
- 36
1 Answers
9
You are close, but you need to rearrange the order of things.
COUNTD(IF [Status] = "COMPLETE" THEN [Survey ID] END)
This will return a Survey ID
if the Status
is 'COMPLETE' otherwise it will return a NULL
to the COUNTD
function. NULL
s are ignored, so they won't be counted.

Nick
- 7,103
- 2
- 21
- 43
-
For the sake of clarity later on, it might help to explicitly state `ELSE NULL` – Andy Sep 28 '18 at 18:35
-
1@Nicarus I'm a newbie and tableau.. and thanks for your help. :) – Arsee Sep 28 '18 at 18:38