COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: jspin on 22 Nov 2023 02:04:21 PM

Title: IF Then Else with Days Between
Post by: jspin on 22 Nov 2023 02:04:21 PM
Hello, I am currently trying to write an IF Then Else statement with days between. I was receiving parsing errors originally, but have alleviated that issue.

The idea of the statment is if a case is unassigned, I want to count the days between todays day and the case creation date to see how long it has been unassigned. However if the case state is assigned i simply want it to return the word assigned.

The below statement returns no errors when verified, but when i try to run the report with this new column i get a message that "the report could not run because a server error occurred." I am new to this, so any insight is very appreciated.

If ([Case State Description] = 'Unassigned') then (days_between (CURRENT_DATE,[Case Create Date])) else ('Assigned')
Title: Re: IF Then Else with Days Between
Post by: bus_pass_man on 23 Nov 2023 07:43:51 AM
The error, once you get it from the log directory (probably from the xqe directory), will probably be complaining about the mismatch of data types.   The data type of the result of the function of days between will probably be an int of some sort.  They don't mix well with strings.   You will probably need to cast the days between result into a string. 


Title: Re: IF Then Else with Days Between
Post by: cognostechie on 23 Nov 2023 12:32:40 PM
Quote from: jspin on 22 Nov 2023 02:04:21 PMIf ([Case State Description] = 'Unassigned') then (days_between (CURRENT_DATE,[Case Create Date])) else ('Assigned')

_days_between will return an integer number whereas 'Assigned' is a character so that is a mismatch in datatypes.
Title: Re: IF Then Else with Days Between
Post by: jspin on 27 Nov 2023 09:35:12 AM
Thank you both for the replies