COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: yokboylebirsey on 15 Apr 2013 05:52:45 AM

Title: Filtering Specific Code's Date
Post by: yokboylebirsey on 15 Apr 2013 05:52:45 AM
Hi gurus,

I need to make a report which shows some codes dates. My report members are;
What I want to do is filter and order work codes. For example, if "A" code does exist for a employee take "A" code and ignore others, if "A" code does not exist then take "B" code else take "C" code, if none of them exist show "null". The order is important, every employee should got 1 date and they shouldn't duplicate because of diffrent codes, if a employee has "a" and "c" code, the filter has to ignore the "c" code and take "a".

The list should be like this:


EMPLOYEE     CODES     DATES
AAA BBBBBB        A         01.04.2013
SSSS DDDDD       A         02.04.2013
FFFF GGGGGG      C         01.04.2013
EEEE RRRRRR       B         05.04.2013
CCCC BBBBBB      C         07.04.2013
OOOO BYYYYB      null      --.--.----

There is a lot of codes but I interest 3 of them and their ordes. I tried case and if statement but i couldn't achieve it.

Thanks,
yokboylebirsey
Title: Re: Filtering Specific Code's Date
Post by: RKMI on 15 Apr 2013 11:13:03 AM
What was your case statement and what was the returned output?

Thanks,
RK
Title: Re: Filtering Specific Code's Date
Post by: yokboylebirsey on 16 Apr 2013 01:17:23 AM
My case statement was
case([WORK_CODE])
WHEN 'A' THEN 'A'
WHEN 'B' THEN 'B'
WHEN 'C' THEN 'C'
ELSE
'NONE'
END

I know, it's missing something this statement.
My output was


EMPLOYEE     CODES     DATES
AAA BBBBBB        A         01.04.2013
AAA BBBBBB       B         01.04.2013
AAA BBBBBB      C         01.04.2013
EEEE RRRRRR       B         05.04.2013
CCCC BBBBBB      C         07.04.2013
OOOO BYYYYB      null      --.--.----
As you can see, there is 3 rows for "AAA BBBBBB", I need to ignore 2 of them(B&C), cause the order is A-->B-->C.
Title: Re: Filtering Specific Code's Date
Post by: BigChris on 16 Apr 2013 02:09:34 AM
I think your CASE statement is working correctly - what you perhaps need to do is group on the Employee Code and find the minimum code in one query. THen link that query back to your code to get the date for that code.
Title: Re: Filtering Specific Code's Date
Post by: yokboylebirsey on 16 Apr 2013 07:43:00 AM
Thanks BigChris, but i guess it's getting complicated, is there any way to solve this problem?
Title: Re: Filtering Specific Code's Date
Post by: BigChris on 16 Apr 2013 08:35:21 AM
It's hard to tell from the data that you've posted, but is there a different way of looking at the problem? Your data suggests that A happens before B and that B hapens before C. Could your query be constructed to be a bit more like:

[Employee], [Date], minimum([Codes] for [Employee], [Date]). You'd need to group the data on [Employee] and [Date], which in turn should bring back something that looks like:


EMPLOYEE       CODES        DATE
AAA BBBBBB       A         01.04.2013
EEEE RRRRRR      B         05.04.2013
CCCC BBBBBB      C         07.04.2013


Obviously I might have that round my neck, but it might be worth investigating...
Title: Re: Filtering Specific Code's Date
Post by: yokboylebirsey on 17 Apr 2013 12:45:47 AM
Sorry for misunderstanding but minimum([codes]) is not what I want. On some cases "A" could be after "B" or "C" however I need "A" code on those circumstances. For this reason, I should order them while filtering, but how?