COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Cognos_Jan2017 on 16 Mar 2017 05:03:48 PM

Title: Should Be A "Simple If Then Else", but ...
Post by: Cognos_Jan2017 on 16 Mar 2017 05:03:48 PM
Running Cognos 10.2.2
Have 2 Query Calculations in adjacent columns ... My code has Fully Qualified Paths, but below are simplified to just Query Item/ Field names ...
1 - DiffDays ... to show [Created Date] has been entered, closing the Incident ...
_days_between(cast([Created Date], date) , Cast([Date Of Incident], date))

2 - ContinueDays ... to show [Created Date] has NOT been entered, meaning Incident unresolved ...
_days_between(current_date, [Date Of Incident])

We need a "Simple" If to test if [Created Date] Is NULL, so ...
If [Created Date] Is NULL
Then
_days_between(current_date, [Date Of Incident])
Else
_days_between(cast([Created Date], date) , Cast([Date Of Incident], date))
... BUT isn't working.

HHEELLPP ... TIA, Bob
Title: Re: Should Be A "Simple If Then Else", but ...
Post by: tjohnson3050 on 16 Mar 2017 06:36:12 PM
Try using coalesce instead.  Returns the first non null value.

_days_between(cast(coalesce([Created Date],current_date),date),cast([Date Of Incident],date))
Title: Re: Should Be A "Simple If Then Else", but ...
Post by: Cognos_Jan2017 on 16 Mar 2017 07:05:08 PM
THANK you.  It WORKS !!!

Too many years VB/ VBA relying on If Then Else, and Select Case.

I now have a new Tool in the Toolbox.