Page 1 of 1

Ancestor function Versus More than 1 parent

Posted: Fri Oct 19, 2012 11:35 pm
by fcapell
Hi everyone,

I'm a newbie working with Report Studio (Cognos 10.1.1) reading from a TM1 data source. I'm dealing with a Time dimension which has hierarchies like this:

- 2012-01-01_YTD
|-- 2012-01-01
- 2012-01-02_YTD
|-- 2012-01-01
|-- 2012-01-02
[...]
- Total 2012 per week
|-- 2012_week_0
|-- 2012-01-01
|-- 2012-01-02
[...]

The report has a Date Prompt. I have to select the 'total week' of that date chosen by the user. So I created a data item with an expression to return this element. I have tried these expressions (I have hardcoded the dates for testing purposes):

parent([Daily Sales].[Period Days].[Period Days]->:[TM].[Period Days].[Period Days].[@MEMBER].[2012-01-01])
ancestors([Daily Sales].[Period Days].[Period Days]->:[TM].[Period Days].[Period Days].[@MEMBER].[2012-01-01], 1)

Both return the element [2012-01-01_YTD].

How can I control which parent will be returned?

Thank you!

Re: Ancestor function Versus More than 1 parent

Posted: Sat Oct 20, 2012 9:10 am
by Michel Zijlema
Hi,

In your example the ancestor function will pick up the first parent of the first hierarchy encountered.
If you have multiple hierarchies you could combine the parent, ancestor (or ancestors) function in combination with the descendants function to pick the parent within the required context.

Michel

Re: Ancestor function Versus More than 1 parent

Posted: Mon Oct 22, 2012 6:24 pm
by fcapell
Thank you for your reply, Michel.
fcapell wrote:If you have multiple hierarchies you could combine the parent, ancestor (or ancestors) function in combination with the descendants function to pick the parent within the required context.
I'm not sure if I got you, but I think you're suggesting that I kinda intersect 2 sets: one with the ancestors of 2012-01-01; and another set with the descendants of 'Total 2012 per week'. Assuming that, in this case it won't work because neither ancestor or parent functions will return the '2012_week_0' (which would be the common element in both sets).

Best regards,

Fausto

Re: Ancestor function Versus More than 1 parent

Posted: Mon Oct 22, 2012 7:57 pm
by fcapell
The funny thing is: I can bring the '2012_week_0' using TM1 subset screen. Here are the steps:

[1] Click on View menu > Expression Window;
[2] Click on Tools > Record Expression;
[3] Click on 'All' button;
[4] Click on 'Filter by Wildcard' button and type '2012-01-01';
[5] Click on the '2012-01-01' element and then click on 'Roll Up' button.

This gave me all the ancestors of 2012-01-01. The expression recorded was:

Code: Select all

{ TM1ROLLUP( {TM1FILTERBYPATTERN( {TM1SUBSETALL( [Period Days] )}, "2012-01-01")}, { [Period Days].[2012-01-01] }) }
On the other hand, if I issue the following expression, it will bring only the 2012-01-01_YTD element:

Code: Select all

ANCESTORS([Period Days].[2012-10-22], 1)
Is there a way of doing something like TM1ROLLUP in Report Studio?

Best regards,

Fausto