COGNOiSe.com - The IBM Cognos Community

Legacy Business Intelligence => COGNOS ReportNet => Topic started by: dgleason42 on 02 Mar 2006 11:44:12 AM

Title: Empty Query on Report - How to Determine
Post by: dgleason42 on 02 Mar 2006 11:44:12 AM
I have several reports that have multiple queries. I'd like to direct to one page if a specific query in the report is empty, but the rownumber() report function seems to not work if one query is blank and another is not. I've also tried using a field from the query in question and the IS NULL, IS MISSING, = "" operators, but it doesn't seem to resolve to true. Does anyone know how to test a query in a report with many queries to see if the query results are empty? The examples already demonstrated here (that I saw via a search) seem to only apply to a single list.
Title: Re: Empty Query on Report - How to Determine
Post by: cognoid1 on 02 Mar 2006 11:52:43 AM
I have the exact same question.  Please share the result.

Thank you.
Title: Re: Empty Query on Report - How to Determine
Post by: bdybldr on 03 Mar 2006 08:10:45 AM
Try adding a data item to all your queries and define them as "Running-count([fieldName])" and name it something unique in each query (ex. rowCntSales, rowCntEmp, etc)

Then define your variable:

(rowCntSales = 0) OR (rowCntEmp = 0) OR ...

HTH.  Please keep us posted.
Title: Re: Empty Query on Report - How to Determine
Post by: dgleason42 on 03 Mar 2006 05:36:14 PM
That sounds like a good suggestion, but unfortunately it doesn't seem to work. If I add that data item into the list and there is data, it looks fine - but if I put a filter on the data and the query returns no rows, then nothing is put into that data item at all, not even a 0 - no rows exist for the query, so no number is displayed.

I guess this would be like in SQL where you create a query with a derived column - even if you hard code something in that column, there won't be any rows if the WHERE clause restricts there from being any rows returned.

This is quite frustrating! It would seem logical that there would be some way to determine if a particular query in a report returned rows or not, regardless of whether other queries in the report did. Oh well, still hunting...I guess I may have to punt and create a single stored procedure or UDF that evaluates the same filter(s) and returns a scalar value.
Title: Re: Empty Query on Report - How to Determine
Post by: CoginAustin on 03 Mar 2006 08:11:33 PM
use the FOR report syntax?

total(SalesAmount for Report)?