COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: awais on 03 Oct 2017 06:02:14 AM

Title: Problem with Maximum Function
Post by: awais on 03 Oct 2017 06:02:14 AM
I am facing an issue with the following statement:

maximum([Timestamp] for [Unique])

My Table doesn't have any unique Attribute, so I created a Unique data item with name Unique by combining 3 data items.

Expression Definition of [Unique] is:

[Entity Name] + [Resource] + [Business Unit]


When I verify my maximum query I get multiple errors:

QE-DEF-0458 CCL Exception
RQP-DEF-0149 The Query specification is incorrect.
RQP-DEF-0217 Wrong Expression Type: maximum([Timestamp] for any [Unique])
Title: Re: Problem with Maximum Function
Post by: MFGF on 03 Oct 2017 07:11:42 AM
Quote from: awais on 03 Oct 2017 06:02:14 AM
I am facing an issue with the following statement:

maximum([Timestamp] for [Unique])

My Table doesn't have any unique Attribute, so I created a Unique data item with name Unique by combining 3 data items.

Expression Definition of [Unique] is:

[Entity Name] + [Resource] + [Business Unit]


When I verify my maximum query I get multiple errors:

QE-DEF-0458 CCL Exception
RQP-DEF-0149 The Query specification is incorrect.
RQP-DEF-0217 Wrong Expression Type: maximum([Timestamp] for any [Unique])

How about:

maximum([Timestamp] for [Entity Name], [Resource], [Business Unit])

MF.
Title: Re: Problem with Maximum Function
Post by: awais on 03 Oct 2017 08:04:44 AM
No Luck still receiving the same error.
Title: Re: Problem with Maximum Function
Post by: MFGF on 04 Oct 2017 03:44:56 AM
Quote from: awais on 03 Oct 2017 08:04:44 AM
No Luck still receiving the same error.

Hi,

Ok. A couple of basic questions:
1. Are you using a relational package or a dimensional package
2. Where are you using this expression - filter? query calculation? layout calculation? elsewhere?

MF.
Title: Re: Problem with Maximum Function
Post by: awais on 05 Oct 2017 08:17:07 AM
Hello,

1. Are you using a relational package or a dimensional package
    The package is relational.

2. Where are you using this expression - filter? query calculation? layout calculation? elsewhere?
     I am using the expression in Filter.

- AR
Title: Re: Problem with Maximum Function
Post by: MFGF on 05 Oct 2017 09:29:55 AM
Quote from: awais on 05 Oct 2017 08:17:07 AM
Hello,

1. Are you using a relational package or a dimensional package
    The package is relational.

2. Where are you using this expression - filter? query calculation? layout calculation? elsewhere?
     I am using the expression in Filter.

- AR

Is that the entire expression? A filter expression should equate to a True or a False result

eg maximum([Timestamp] for [Entity Name], [Resource], [Business Unit]) = <some specific value you want to compare it with>

Are you simply missing part of your filter expression, or is there more of it you haven't told us?

MF.
Title: Re: Problem with Maximum Function
Post by: awais on 09 Oct 2017 05:58:03 AM
I can not compare it with a specific Value. I just want to fetch the latest occurrence for the given Parameters.
Title: Re: Problem with Maximum Function
Post by: Lynn on 09 Oct 2017 06:10:21 AM
Quote from: awais on 09 Oct 2017 05:58:03 AM
I can not compare it with a specific Value. I just want to fetch the latest occurrence for the given Parameters.

If you are not comparing it with anything else then it doesn't make any sense as a filter expression. A filter reduces the rows returned from a query by comparing some value in the database with some other value to determine if the record should be included or not in the result set. For example, comparing a transaction date in the database with today's date to see transactions that occurred today.

What is your intended use for this item if not to use for filtering? Perhaps it just needs to be a data item in the query to be displayed?
Title: Re: Problem with Maximum Function
Post by: awais on 09 Oct 2017 06:21:16 AM
Thanks for the comment lynn, is there any alternate to return the latest occurrence on the basis of Time-stamp  ?
Title: Re: Problem with Maximum Function
Post by: Lynn on 09 Oct 2017 07:10:17 AM
Quote from: awais on 09 Oct 2017 06:21:16 AM
Thanks for the comment lynn, is there any alternate to return the latest occurrence on the basis of Time-stamp  ?

This is basically what MFGF suggested previously, but not sure I am fully understanding what you want to do:

maximum( [Timestamp] for [Entity Name], [Resource], [Business Unit]) = [Timestamp]

That expression would determine the latest timestamp for the scope indicated and compare that with the values in your database to retrieve only the latest occurrence (e.g., the one that matches the result of the maximum calculation).

Your last post suggested you cannot compare the maximum value with anything so not sure what I am not understanding. You also mentioned "given Parameters" although I don't see any mention of parameters in the thread but assumed you just meant entity name, resource, and business unit.

Title: Re: Problem with Maximum Function
Post by: awais on 10 Oct 2017 05:45:55 AM
Thanks it solved my error. :)