COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Esperanza on 04 May 2015 01:18:33 PM

Title: CurrentDate in a Detail filter
Post by: Esperanza on 04 May 2015 01:18:33 PM
Hello Cognos Experts!

Before running the report, I want to test if we are the first day of the month or not, if yes, then I want to run the report for the previous fiscalPeriod.

Here is what I put in the a Detail filter expression :

if (current_date=_first_of_month (current_date))
then
([GM].[Dim Time Fiscal].[Fiscal Month Id]=?p_Period?-1)
else
([GM].[Dim Time Fiscal].[Fiscal Month Id]=?p_Period?)
I always got this error
RSV-SRV-0042(see attachement)
------------------------------------------------------------------------------------

I don't understand because the condition work well in a dataItem
if (current_date=_first_of_month (current_date))
then('YES') else
('No')
Title: Re: CurrentDate in a Detail filter
Post by: CognosAnalytics on 04 May 2015 08:04:40 PM
Hello CognosTuner,
I believe, your filter expression should be as such...

[GM].[Dim Time Fiscal].[Fiscal Month Id] =
if (current_date=_first_of_month (current_date))
then
(?p_Period?-1)
else
(?p_Period?)


-Cognos810
Title: Re: CurrentDate in a Detail filter
Post by: Lynn on 05 May 2015 04:00:29 AM
Quote from: CognosTuner on 04 May 2015 01:18:33 PM
Hello Cognos Experts!

Before running the report, I want to test if we are the first day of the month or not, if yes, then I want to run the report for the previous fiscalPeriod.

Here is what I put in the a Detail filter expression :

if (current_date=_first_of_month (current_date))
then
([GM].[Dim Time Fiscal].[Fiscal Month Id]=?p_Period?-1)
else
([GM].[Dim Time Fiscal].[Fiscal Month Id]=?p_Period?)
I always got this error
RSV-SRV-0042(see attachement)
------------------------------------------------------------------------------------

I don't understand because the condition work well in a dataItem
if (current_date=_first_of_month (current_date))
then('YES') else
('No')

I would generally avoid case or if/else logic in a detail filter. Try using an expression that evaluates to a Boolean situation.


(
  current_date = _first_of_month (current_date)
  and
  [GM].[Dim Time Fiscal].[Fiscal Month Id] = ?p_Period?-1
)
or
(
  current_date <> _first_of_month (current_date)
  and
  [GM].[Dim Time Fiscal].[Fiscal Month Id]=?p_Period?
)