COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: sujitgouda on 24 Feb 2016 11:47:16 AM

Title: using case statement in filter
Post by: sujitgouda on 24 Feb 2016 11:47:16 AM
Hi All,

I am trying to pass a parameter to a filter and using the below case statement to execute the report based on the value of the parameter.
What i want to achieve is; if Paramdate = First Day of Month Then use reporting date = paramdate else use the range for settled date from (passed paramdate to start of the month) to run the report.

Parameter Name:   ?paramReportingDate?

case
when ?paramReportingDate?  = _first_of_month(?paramReportingDate?) then [Sales Reporting (Query)].[Trade Details].[Reporting Date] = ?paramReportingDate?
else [Sales Reporting (Query)].[Trade Details].[Settled Date]  between _first_of_month (?paramReportingDate?) and ?paramReportingDate?
end


I am getting an parsing error everytime :(

Please help me.
Title: Re: using case statement in filter
Post by: Rosanero4Ever on 24 Feb 2016 11:53:37 AM
Hi,

you can use the following statement:
( ?paramReportingDate?  = _first_of_month(?paramReportingDate?) and  [Sales Reporting (Query)].[Trade Details].[Reporting Date] = ?paramReportingDate? )
OR
(
[Sales Reporting (Query)].[Trade Details].[Settled Date]  between _first_of_month (?paramReportingDate?) and ?paramReportingDate?
)



I hope this help you
Title: Re: using case statement in filter
Post by: sujitgouda on 25 Feb 2016 11:32:52 AM
That did help in resolving the parsing error.

But the output when I use only Filter 1 and Filter 2 are not matching for paramDate - 20160218

Filter 1: [Sales Reporting (Query)].[Trade Details].[Settled Date]  between _first_of_month (?paramReportingDate?) and ?paramReportingDate?

Filter 2: (
(
?paramReportingDate?  = _first_of_month(?paramReportingDate?) and  [Sales Reporting (Query)].[Trade Details].[Reporting Date] = ?paramReportingDate?
)
OR
(
[Sales Reporting (Query)].[Trade Details].[Settled Date]  between _first_of_month (?paramReportingDate?) and ?paramReportingDate?
)

)





Title: Re: using case statement in filter
Post by: BigChris on 26 Feb 2016 02:07:15 AM
Presumably Filter 2 is giving you higher results than Filter 1. They're different filters, so you're going to get different results.For example, anything where the ReportingDate is the 18th of Feb, but the Settled Date is later than the 18th of Feb (using your data) would be included in Filter 2 but not in Filter 1.