Hi all can someone please point out what's wrong with my count here? below is what my expression is and below that is the error.
case when ([Presentation].[Risk Register].[Status] = 'Open')
then ((count([Presentation].[Risk Register].[Risk ID] for [Presentation].[Projects].[Project Name]))
else ('0')
end
Incompatible data types in case statement
The error message is complaining that there's incompatible data types.
You are creating a numeric data type with the count and creating a string with the '0'.
Quote from: et21 on 19 Jul 2022 05:47:16 PM
Hi all can someone please point out what's wrong with my count here? below is what my expression is and below that is the error.
case when ([Presentation].[Risk Register].[Status] = 'Open')
then ((count([Presentation].[Risk Register].[Risk ID] for [Presentation].[Projects].[Project Name]))
else ('0')
end
Incompatible data types in case statement
Hi,
This expression is returning a numeric value for the 'then' clause and a character value for the 'else' clause. You need to return values of the same data types. One option is to remove the single quotes from around the '0' in the 'else' clause so that both clauses return numeric values. The other option is to cast the count from the 'then' clause to a char or varchar value so that both clauses return character values.
Cheers!
MF.
This always works for me:
count (distinct
case when ( )
then ( )
)
No need for else