COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: Cape Cod Gunny on 11 Feb 2022 10:36:18 AM

Title: Using "IN" vs using "=" as a detail filter inside a query?
Post by: Cape Cod Gunny on 11 Feb 2022 10:36:18 AM
I'd like to understand the best way to restrict items in a query. For example Query1 returns a list of ID's based of specific detail filters. I would like Query2 to return only items where Query2.ID matches Query1.ID.

Which Query2 Detail Filter is better? And why?

Query2.ID IN ( Query1.ID )
Query2.ID = Query1.ID
Note: Using an "=" filter requires Query2's "Cross product allowed" property to be set to "Allow".
Title: Re: Using "IN" vs using "=" as a detail filter inside a query?
Post by: dougp on 11 Feb 2022 10:41:06 AM
You need a join, not a filter.
Title: Re: Using "IN" vs using "=" as a detail filter inside a query?
Post by: MFGF on 11 Feb 2022 10:55:09 AM
Quote from: Cape Cod Gunny on 11 Feb 2022 10:36:18 AM
I'd like to understand the best way to restrict items in a query. For example Query1 returns a list of ID's based of specific detail filters. I would like Query2 to return only items where Query2.ID matches Query1.ID.

Which Query2 Detail Filter is better? And why?

Query2.ID IN ( Query1.ID )
Query2.ID = Query1.ID
Note: Using an "=" filter requires Query2's "Cross product allowed" property to be set to "Allow".

Hi,

I second Doug's approach. The best option is to join the two queries, with a mandatory cardinality (probably 1..1 <--> 1..1). This will be much more efficient than trying to use cross products.

Cheers!

MF.
Title: Re: Using "IN" vs using "=" as a detail filter inside a query?
Post by: Cape Cod Gunny on 11 Feb 2022 11:51:16 AM
Thank you both for your input.
Title: Re: Using "IN" vs using "=" as a detail filter inside a query?
Post by: MFGF on 11 Feb 2022 12:12:37 PM
Quote from: Cape Cod Gunny on 11 Feb 2022 11:51:16 AM
Thank you both for your input.

You're welcome! Let us know how it goes :-)

Cheers!

MF.