COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: bberryhill on 14 Apr 2014 03:00:38 PM

Title: Rank not working with tree prompt for date
Post by: bberryhill on 14 Apr 2014 03:00:38 PM
I am having a problem with the Rank function when the user selects multiple dates from a tree prompt.  I am pretty sure the problem is related to getting multipe members back in the prompt.  I have a data item [SelectedPeriods] that contains a prompt macro:

#promptmany('pSelectedPeriods','memberuniquename', '', 'set(', ' [Dimensions].[Date].[Date].[Year] ', ')' )#

I am using the data item [SelectedPeriods] as a slicer.  If the user selects a single data item, '2014', the rank works correctly, but if the user selects multiple data items, '2013 Q4' and '2014 Q1' for example, the rank is not calculated, I get '--' instead.

Thanks in advance for your help.
Title: Re: Rank not working with tree prompt for date
Post by: navissar on 16 Apr 2014 08:04:31 AM
rank is a relational function. Tree prompts belong in dimensional. try using topCount instead.
Title: Re: Rank not working with tree prompt for date
Post by: bberryhill on 18 Apr 2014 10:41:01 AM
I have a TopCustomers set expression that is using the topCount
topCount( filter( [Dimensions].[Customer].[Customer].[Customer],[Quantity] <> null ) , ?pTopCustomerCount?, [Revenue] )

This returns the set of top customers but does not enumerate them.

The "AUTHOR REPORTS WITH MULTIDIMENSIONAL DATA (V10.2)" describes rank as a dimensional function
rank (numeric_expression [ASC|DESC] [tuple member_expression { , member_expression }] within set set_expression)

It does seem somewhat redundant to get a set of top customers and then rank them - but how else can I enumerate the list and sort the list asc or desc?
Title: Re: Rank not working with tree prompt for date
Post by: navissar on 18 Apr 2014 03:45:28 PM
Well, you could sort them by the actual measure...  8)
Title: Re: Rank not working with tree prompt for date - Resolved!
Post by: bberryhill on 07 May 2014 10:02:34 AM
I was able to resolve this issue using the dimensional format for rank.  My final expression was:

rank( [Revenue] within set [TopCustomers] )

I also removed the filter from my topCount expression winding up with:

topCount([Dimensions].[Customer].[Customer].[Customer],?PTopCustomerCount?,[Revenue])

The filter function was redundant and slowed down the results. I probably put it in there while building the report basics and never took it out.