scripts in Advanced Tab

Post Reply
charan
Posts: 148
Joined: Tue Nov 23, 2010 9:04 am
OLAP Product: cognos tm1
Version: 9.5
Excel Version: 2007

scripts in Advanced Tab

Post by charan »

Hi,

I have tried to create a dimension using TI script. The procedure I have done is,

1) I have channles.csv file as text source.

2) Content column Other

3) In advance tab under "PROLOG" tab I have written DImension create('Test_Channel');

4) In "METADATA" tab DImensionElementComponentADD('Test_Channel','AllChannels','GolfShop',1);

For this I got an error "Dimension creation fails"

Later step: 3 above i have included in "Metadata" tab.

For that I have got an error as above mention error.

I have searched in our site for this. Please help me how to create a dimension(it should be dynamic) using Scripts.


TM1 10.1
excel2010

Thank you
Alan Kirk
Site Admin
Posts: 6654
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: scripts in Advanced Tab

Post by Alan Kirk »

charan wrote:Hi,

I have tried to create a dimension using TI script. The procedure I have done is,

1) I have channles.csv file as text source.

2) Content column Other

3) In advance tab under "PROLOG" tab I have written DImension create('Test_Channel');

4) In "METADATA" tab DImensionElementComponentADD('Test_Channel','AllChannels','GolfShop',1);

For this I got an error "Dimension creation fails"

Later step: 3 above i have included in "Metadata" tab.

For that I have got an error as above mention error.

I have searched in our site for this. Please help me how to create a dimension(it should be dynamic) using Scripts.
Please don't just type the text of code into questions; if you copy it directly from your process and paste it into a code block, it's possible to spot typos and the like. (The code clearly couldn't have been "Dimension create" because that wouldn't compile; it would have to have been DimensionCreate.) When you just type it into the message it's impossible to be sure that you haven't typed what you think is there rather than what's really there.

However I don't think that a typo is your problem in this case.

When you're updating a dimension you can use (for example) DimensionElementInsert to try to insert an element that is already present without doing any harm.

However the DimensionCreate statement is different; if you already have the dimension on the server, it will fail with a:

Code: Select all

Error: Prolog procedure line (6):  Dimension creation fails for dimension "Test_Channel".
error. And since you had run the process before (with the DimensionCreate in your prolog) then unless you manually deleted the dimension you WILL run into that problem.

(Or you could delete it in your TI using DimensionDestroy, but there you'll run into problems if the dimension is used in any cubes; you'd have to delete the cubes first.)

If you really want to have the DimensionCreate in the process then I would put it as:

Code: Select all

# Only create the dimension if it doesn't exist.
If ( DimensionExists('Test_Channel') =0 ) ;
    DImensionCreate('Test_Channel');
EndIf;
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
charan
Posts: 148
Joined: Tue Nov 23, 2010 9:04 am
OLAP Product: cognos tm1
Version: 9.5
Excel Version: 2007

Re: scripts in Advanced Tab

Post by charan »

Hi Alan,
Thank you. There is no dimension Test_channel created before on this server, this is the first time I am creating.

So, for creating a new dimension, I have to write scripts like in Prolog tab,

DImension exists.
Dimension create.
DImensionElementInsert.

Here I have one doubt, If my dimension contains One consolidated element with N number of leaf elements how to write script for it.If I has N levels of consolidated elements with the leaf elements how wirte script for it(this scripts to be written in metadata tab?).

Please suggest me.

Thank you.
charan
Posts: 148
Joined: Tue Nov 23, 2010 9:04 am
OLAP Product: cognos tm1
Version: 9.5
Excel Version: 2007

Re: scripts in Advanced Tab

Post by charan »

please any suggestions
Alan Kirk
Site Admin
Posts: 6654
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: scripts in Advanced Tab

Post by Alan Kirk »

charan wrote:please any suggestions
Only patience. It's two days before Christmas, a time which is often mandatory annual leave, and it's a Sunday to boot. I doubt that many people are spending a lot of time in places like this at the moment. I've also got a stack of seasonal e-mails that I have to reply to and at this time of the year I doubt that I'm the only one.
charan wrote: Thank you. There is no dimension Test_channel created before on this server, this is the first time I am creating.
All I can tell you is that the error message that you got is one that you get when the dimension already exists.
charan wrote:So, for creating a new dimension, I have to write scripts like in Prolog tab,

DImension exists.
Dimension create.
DImensionElementInsert.
That may be what you read but it's at more than a little variance with what I wrote.

You need to go back to the basics.

What does the Prolog tab do? It runs the code on that tab once, before any rows of your data file are processed. In this case it runs before any lines of your channles.csv (as you've typed it) file are read.

So yes, you can create the dimension in there. However you should re-read the exact code that I posted; you check whether the dimension exists and only create it if you confirm that it doesn't.

You can also insert elements (both N level and consolidations) into the dimension (using DimensionElementInsert) on this tab. However the element names must be ones that you already know; they can't be from your .csv file because that hasn't been read at that point.

You can also update consolidations via DimensionElementComponentAdd and DimensionElementComponentDelete on this tab but again, you can only do it if you know the names of the elements.

Now what does the Metadata tab do?

It reads your source file line by line. You use the values in each line to update the metadata on your server, such as by creating elements or updating consolidations.

Again, to insert elements you can use DimensionElementInsert but this time instead of using fixed names you can use the names that appear on the rows of the file.

In most cases when doing this kind of update you'll have at least two columns; one telling you the name of the child element, and one telling you the name of the parent element.

In other words it might look like this:

Code: Select all

Row No     Child                       Parent Consolidation
1              Germany                 Central Europe
2              Poland                    Central Europe
3              Central Europe        Europe
4              USA                       North America
Child would be one variable, Parent Consolidation would be the other.

To put the child under the consolidation, you just use the DimensionElementComponentAdd function.

When all of the rows of your file have been read then the metadata (dimensions) are updated and you have the updated dimension on the server.

So let's look at your question in the light of that.
charan wrote:Here I have one doubt, If my dimension contains One consolidated element with N number of leaf elements how to write script for it.
If you mean that you have one consolidation with all of the elements your data file under it then:
- You can create the consolidation element in either the Prolog or the Metadata tab, but it's probably more efficient to do it in the Prolog tab); and
- Use the DimensionElementComponentAdd function on the Metadata tab to add the element named on each row of your data file to that consolidation.
charan wrote:If I has N levels of consolidated elements with the leaf elements how wirte script for it(this scripts to be written in metadata tab?).
Not sure I follow this bit. If you mean "how do I create a hierarchy" then as long as your source file has both parent and child elements (as per the example above) then the hierarchy is automatically created as you do the DimensionElementComponentAdds.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
Post Reply