COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: mark123 on 20 Jan 2016 09:01:56 AM

Title: How to compare text/date between two columns
Post by: mark123 on 20 Jan 2016 09:01:56 AM
I have a report in which in one data item while writing case statement i need to check two name columns contains same  name or not(condition 1).
Similarly i need to check if date matches between two date columns(condition 2).

I am writing
case
when
(condition 1) and (condition 2)
then

end

Can i directly compare by keeping = between the two columns or is there separate syntax for comparing two text and date columns.

Thanks,
Mark
Title: Re: How to compare text/date between two columns
Post by: BigChris on 20 Jan 2016 09:51:13 AM
If I'm reading your question correctly (and forgive me if I'm not), you can certainly write a calculation that's along the lines of:

Case
when [Field1] = [Field2] and [Date1] = [Date2] then 'Success'
else 'Failure'
End


You might need to do some fiddling with formats, for example casting the dates if you need to get rid of time elements, or trimming text fields to get rid of trailing spaces.
Title: Re: How to compare text/date between two columns
Post by: mark123 on 20 Jan 2016 10:04:43 AM
Thanks Chris