COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: godawgs85 on 05 Jun 2013 12:32:17 PM

Title: Count Function (ability to reference Member Set in Column
Post by: godawgs85 on 05 Jun 2013 12:32:17 PM
Hi Everyone,

I have a dilemma I am facing.  Ultimately I am trying to create a count function in a crosstab column which will count the descendants of whatever member is in the applicable row.  For example, here is the function set up as a data item in a column:

count (1 within set descendants ([Management Company],1))

So if have Management Company as the specified member in the applicable row, it gives me the appropriate # of descendants.  If I have another member from a separate heirarchy, however, such as [Brand], the function gives me an error obviously.  My question is is there a way to reference the member in the row rather than having to explicitly define the member within the count function?

Thanks!
Title: Re: Count Function (ability to reference Member Set in Column
Post by: MFGF on 05 Jun 2013 12:38:33 PM
Hi,

The big question here is how you are substituting the member in the row - is it a fixed member dragged in from the package tree, or are you using some sort of prompt to drive the member?  If you're using a prompt, you could change approach to make it a macro-driven expression which builds the MUN of the desired member, then use this calculated member in your count function?

Just a thought...

MF.
Title: Re: Count Function (ability to reference Member Set in Column
Post by: godawgs85 on 05 Jun 2013 03:40:27 PM
That's a good idea, but the row values are static (from the package tree) and won't typically change.  I could look into this though.  Do you think there any way to get the count function to reference different members using a case or if/function?

Thanks!
Title: Re: Count Function (ability to reference Member Set in Column
Post by: CognosPaul on 06 Jun 2013 08:34:44 AM
Can you post the report XML or a screenshot of how your crosstab is set up?
Title: Re: Count Function (ability to reference Member Set in Column
Post by: godawgs85 on 06 Jun 2013 10:39:39 AM
Attached is a screenshot.  As you can see, the # of Hotels Column is the data item in question in which I'm using the count function.  Obviously I get the correct count for whatever member I use in the function (i.e. [Management Company]), but I would like for the column to have the ability to refer to whatever member is in the row and perform the count of descendants off of that member.  My conflict has been to have the ability to refer to multiple members or something similar to currentMeasure but in regards to members.

Thanks!
Title: Re: Count Function (ability to reference Member Set in Column
Post by: godawgs85 on 10 Jun 2013 02:08:39 PM
Quote from: godawgs85 on 06 Jun 2013 10:39:39 AM
Attached is a screenshot.  As you can see, the # of Hotels Column is the data item in question in which I'm using the count function.  Obviously I get the correct count for whatever member I use in the function (i.e. [Management Company]), but I would like for the column to have the ability to refer to whatever member is in the row and perform the count of descendants off of that member.  My conflict has been to have the ability to refer to multiple members or something similar to currentMeasure but in regards to members.

Thanks!

Does anyone know if this can be done?

Thanks!
Title: Re: Count Function (ability to reference Member Set in Column
Post by: CognosPaul on 10 Jun 2013 02:19:04 PM
 :-[ I forgot about this...

Unfortunately Cognos doesn't have decent enough context awareness to easily support something like this. Depending on the cube technology, maybe you can make a custom measure for this?

One possible solution:

Create a data item for each hierarchy. Drag them into the columns as peers. Select all of the intersections, except for the correct intersections, and set box type to none. Select all of the column nodes and do the same. This will push all of the elements to the left, giving the appearance of the functionality you need.

But if you need to reference that in another calculation, we'll need to think of something else.
Title: Re: Count Function (ability to reference Member Set in Column
Post by: godawgs85 on 10 Jun 2013 03:36:34 PM
Thanks Paul,


That's a good idea but would it have the same functionality when exported to excel?

I think what I might move forward with is to create multiple crosstabs for each hierarchy, that way I can use similar "# Hotels" data items in each crosstab, just with different members in each count function.  It will also give me the ability to refer to it in other calculations if necessary.  These overall hierarchies won't ever change (the underlying # of hotels might), so I should be ok in doing that.  It's a little more work than one crosstab but would give me better efficiencies in getting the count function to work.  I was just wondering if it could be acheived in one crosstab.  I think it ultimately can but might be a lot harder than necessary.

I appreciate your insight.  Thanks
Title: Re: Count Function (ability to reference Member Set in Column
Post by: CognosPaul on 11 Jun 2013 01:35:18 PM
Formatting, such as setting the box-type to none, will carry over to Excel. Unless you do need to reference the # Hotels in another expression, making separate crosstabs won't improve the efficiency at all.

See what happens when you try my suggestion, it should work.