If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

count

Started by et21, 19 Jul 2022 05:47:16 PM

Previous topic - Next topic

et21

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


bus_pass_man

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'.

MFGF

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.
Meep!

cognostechie

This always works for me:

count (distinct
    case when (   )
    then (  )
)

No need for else