COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: tims69camaro on 19 Mar 2024 03:40:54 PM

Title: Filter for latest datetime when multiple data items match.
Post by: tims69camaro on 19 Mar 2024 03:40:54 PM
I'm wanting to filter the below table when dataitem Location and Item match in two or more columns, I only want to keep the latest timestamp occurrence.

Location   Status   Item   Qty   Timestamp
BP1--0-056-A-   75   039094   36   Mar 15, 2024 1:24:35 PM
BP1--0-056-A-   75   073434   0   Mar 15, 2024 1:24:35 PM
BP1--0-056-A-   75   039094   0   Mar 15, 2024 3:05:25 PM
BP1--0-056-A-   75   073434   36   Mar 15, 2024 3:05:25 PM

I'm having trouble coming up with a solution. The results would filter out the top two rows, if it worked.

Any help is appreciated.

Title: Re: Filter for latest datetime when multiple data items match.
Post by: cognostechie on 19 Mar 2024 04:19:17 PM
You can create a filter

Timestamp = maximum(Timestamp for Location, Item)
Title: Re: Filter for latest datetime when multiple data items match.
Post by: tims69camaro on 21 Mar 2024 08:48:12 AM
I figured out a solution. I found a similar issue someone else posted and was able to modify what they did and it worked.

Filter: [Timestamp] = maximum([Timestamp] for [Location],[Item])

I didn't realize I could list multiple data items with comma separation after the "for".

Hope this helps someone in the future. Collaboration is BOSS...
Title: Re: Filter for latest datetime when multiple data items match.
Post by: cognostechie on 21 Mar 2024 05:18:21 PM
Amazing that you 'found a similar issue someone else posted' which was exactly the same as I posted !! Wonderful !