COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: sanchoniathon on 20 May 2015 01:40:20 PM

Title: Parsing error
Post by: sanchoniathon on 20 May 2015 01:40:20 PM
Hello to all,

I'M getting a parsing error while trying to apply the following logic in the data item:
[date] >= _add_months(?pDate?, -CAST(?pMonths?,INTEGER))

Or while trying the following logic:

If ([date] = _add_months (?pDate?, - ?pMonths? ))
Then ( [Total Sales] )
Else (0)


Or while trying the following logic:

[date] between _add_months(#prompt('pDate','token')#, -1* #prompt('pMonths','token')#) and (_add_months(#prompt('pDate','token')#, #prompt('pMonths','token')#))

Or while trying this:

[date] between _add_months(#prompt('?pDate?','token')#, -1* #prompt('?pMonths?','token')#) and (_add_months(#prompt('?pDate?','token')#, #prompt('?pMonths?','token')#))


Am i missing something like doing a cast on the [date] column ? Or something like it ?

Thank you all for any fast reply!
Title: Re: Parsing error
Post by: bdbits on 20 May 2015 02:42:06 PM
Is [date] actually a date? If not, then you need to cast it.

Same with pDate - it needs to be a date as an argument to _add_months().
Title: Re: Parsing error
Post by: sanchoniathon on 20 May 2015 02:44:01 PM
yes [date] is of type DATE TIME and yes pData is a CALENDAR GREGORIAN prompt type.
Title: Re: Parsing error
Post by: Lynn on 20 May 2015 02:44:42 PM
Why don't you try simplifying the expression to get the correct syntax and then add in the necessary complexity bit by bit to isolate where you are going wrong.



[date] >= _add_months(current_date, -3)


then


[date] >= _add_months(?pDate?, -3)


then


[date] >= _add_months(?pDate?, ?pMonths?)


then


[date] >= _add_months(?pDate?, ?pMonths? * -1)


Ah, bdbits got there first with a more concise answer :)
Title: Re: Parsing error
Post by: sanchoniathon on 20 May 2015 03:35:06 PM
Thank you all ... simple comma that i needed to replace by a semiolon ( ; )