Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tableau: COUNTD using IF statement

Tags:

tableau-api

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?

like image 230
Arsee Avatar asked Mar 05 '23 08:03

Arsee


1 Answers

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. NULLs are ignored, so they won't be counted.

like image 129
Nick Avatar answered May 16 '23 08:05

Nick