COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: Cynthia on 25 May 2010 09:53:26 AM

Title: Display First Record Only
Post by: Cynthia on 25 May 2010 09:53:26 AM
I have a report that displays a commodity, and then the related Vendors for that commodity.  It groups everything okay.  Including the vendor.

But I only want to show the most recently used vendor. There are two vendors showing, and I only want to see the first one (most recently used) on the report.  Is there a way to do that?

Maximum doesn't work because it's displaying the maximum of each vendor. And I only want one vendor, not both.

Let me know if I haven't explained this well.
Thanks,
Cynthia

Edit, I'm in Cognos Report Studio 8.4
Title: Re: Display First Record Only
Post by: tupac_rd on 25 May 2010 10:22:02 AM
create a data item running-count([vendor]), and filter the new data item =1, will that work?
Title: Re: Display First Record Only
Post by: Cynthia on 25 May 2010 10:33:58 AM
Doesn't look like it. It wants an amount for the running total, and my fields are attributes (char) and identifiers (date).
Title: Re: Display First Record Only
Post by: Cynthia on 25 May 2010 10:36:04 AM
I've also tried HEAD, but I need to head the max, and i'm getting an error about that too...

invalid coercion from 'value' to 'memberset'
Title: Re: Display First Record Only
Post by: Cynthia on 25 May 2010 11:09:23 AM
I'm looking at using running-count though... thanks for the idea. Maybe running-total would work if I cast the date to an integer, but I'm not sure.

the running-count description says this:
running-count ( numeric_expr  [ at exp {, expr } ]  [ <for-option> ] [ prefilter ] )
running-count ( [ distinct ] numeric_expr  [ <for-option> ] [ prefilter ] )
<for-option> ::= for expr {, expr } | for report | auto
Returns the running count by row (including the current row) for a set of values. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can only be used in the context of relational datasources. The keyword "distinct" is available for backward compatibility of expressions used in previous versions of the product.

But I really don't understand how to use the for-option.  Can anyone give me an example?  :)  I'll look around the forums... but searching for the word 'for' really doesn't work very well!
Title: Re: Display First Record Only
Post by: tupac_rd on 25 May 2010 01:30:31 PM
running-count( [data item1] for report) or

running-count( [data item1] for [data item2])
Title: Re: Display First Record Only
Post by: Cynthia on 25 May 2010 01:55:32 PM
Thanks.

It's still not suppressing the data rows that I want to have not show. I'm looking into Render Variables... but dangit, it's not easy to understand either. :)
Title: Re: Display First Record Only
Post by: elsolo21 on 25 May 2010 02:41:41 PM
Have you tried something like:

max([date] for [vendor]

That should get you the most recent record with the corresponding vendor.
Title: Re: Display First Record Only
Post by: Cynthia on 25 May 2010 02:44:46 PM
Yes, but with the grouping... I have more than one vendor, and it's bringing me up the record for each vendor. I only want the one vendor that has the most recent date.
Title: Re: Display First Record Only
Post by: kattaviz on 25 May 2010 04:23:31 PM
Hi,

You can try using the Singleton object. If you sort your query by date DESC then the Singleton pickup only the first value.

HTH
Title: Re: Display First Record Only
Post by: Cynthia on 25 May 2010 04:51:35 PM
Okay thanks, looking into that.

I need the entire row to not show, though. Not just a single column. 
And it's not letting me sort on the singleton object.
Title: Re: Display First Record Only
Post by: tupac_rd on 26 May 2010 12:18:19 PM
max ( [vendor] for report) will this work
Title: Re: Display First Record Only
Post by: James_Bonnell on 26 May 2010 01:13:42 PM
Hmm.  So each Commodity has a Vendor (or more than one), right?

How about trying a data item with max([Vendor Date] for Commodity)?  That should give you the Vendor, per Commodity, that has the highest date.

You may need to then do a filter setting the (Vendor Date) = max([Vendor Date] for Commodity).  I think that should give you only one Vendor per Commodity, unless of course more than one vendor shares the vendor date...

That's what I'd try...
Title: Re: Display First Record Only
Post by: Sreeni P on 27 May 2010 01:41:50 AM
Have u tried with Singleton?like kattaviz said earlier....