I am trying to distinct count all values in the Incident_ID column where a number of IIF statements are met. The SSTS expression is running but the result is far from correct. When using SQL on SSMS, I am getting totally different results which makes me feel my expression is incorrect. I am also looking at the data and the data backs-up my expression isn't right.
Kindly see below. Many thanks.
=CountDistinct(IIF(Fields!Last_month.Value = 1
AND Fields!Clinic_group.Value = "AAA"
AND Fields!Incident_approval_Flag.Value = 1
AND (Fields!Incident_severity_code.Value <> "BBB"
AND NOT ISNOTHING(Fields!Incident_severity_code.Value))
,Fields!Incident_ID.Value, Nothing)
)