Insert Element in Dimension, Set Attribute

Post Reply
maps
Posts: 43
Joined: Wed Aug 10, 2011 9:21 am
OLAP Product: TM1
Version: 9.4.1 and 9.5.1
Excel Version: 2003

Insert Element in Dimension, Set Attribute

Post by maps »

Hi everyone,

I'm struggeling with updateing a dimension. I just want to load the elements out of a textfile into a dimension and set a attribute 'Status'. But always the following error occurs:

Code: Select all

...Data Source line (1) Error: MetaData procedure line (8): Element "10010." not found in dimension "dim_Empl".
         ...
Line 8 refers to the AttrPutS statement.

MetaData:

Code: Select all

IF( DIMIX( cDimName, vPersID) = 0);
  DimensionElementInsert( cDimName, '', vPersID, 'N');
  IF( DIMIX( cDimName, vPersID) <> 0);
    AttrPutS( 'EXISTS', cDimName, vPersID, cAttrStatus);
  ENDIF;
ELSE;

  AttrPutS( 'ACTIVE', cDimName, vPersID, cAttrStatus);
ENDIF;
Because I always got the error I inserted the second DIMIX statement to ensure that the element of the dimension really exists. What am I doing wrong? Any ideas?
Last edited by maps on Mon Jan 09, 2012 11:00 am, edited 1 time in total.
Edward Stuart
Community Contributor
Posts: 248
Joined: Tue Nov 01, 2011 10:31 am
OLAP Product: TM1
Version: All
Excel Version: All
Location: Manchester
Contact:

Re: Insert Element in Dimension, Set Attribute

Post by Edward Stuart »

Edit: After engaging my brain I realised I was wrong!

Although checking through the help files for AttrInsert/ AttrDelete it doesn't mention where it needs to be placed in the TI process.
Last edited by Edward Stuart on Mon Jan 09, 2012 11:29 am, edited 1 time in total.
User avatar
Michel Zijlema
Site Admin
Posts: 712
Joined: Wed May 14, 2008 5:22 am
OLAP Product: TM1, PALO
Version: both 2.5 and higher
Excel Version: 2003-2007-2010
Location: Netherlands
Contact:

Re: Insert Element in Dimension, Set Attribute

Post by Michel Zijlema »

Hi maps,

Please note that the dimension is only saved after the Metadata run has finished - so all elements that have been added will be available after the MetaData script has completed, this is at the start of the Data run.
Setting attribute values is in fact loading data in the corresponding }ElementAttributes cube. In order to be able to load data, the regarding cell to load needs to be available - this will be after the changes to the required dimensions have been saved. So loading the attribute values will be something you do in the Data tab script, not in the MetaData tab script.

Michel
maps
Posts: 43
Joined: Wed Aug 10, 2011 9:21 am
OLAP Product: TM1
Version: 9.4.1 and 9.5.1
Excel Version: 2003

Re: Insert Element in Dimension, Set Attribute

Post by maps »

But how can I set the attribute with the status? When the metadata tab has finished the element is already in the dimension and it doesn't make any sense to use the dimix statement again. How can I flag that the element didn't exist before using a flag? any advice?
User avatar
Michel Zijlema
Site Admin
Posts: 712
Joined: Wed May 14, 2008 5:22 am
OLAP Product: TM1, PALO
Version: both 2.5 and higher
Excel Version: 2003-2007-2010
Location: Netherlands
Contact:

Re: Insert Element in Dimension, Set Attribute

Post by Michel Zijlema »

maps wrote:But how can I set the attribute with the status? When the metadata tab has finished the element is already in the dimension and it doesn't make any sense to use the dimix statement again. How can I flag that the element didn't exist before using a flag? any advice?
You could create a temporary dimension and list new elements in this dimension. On the data tab you could set the status based on the availablity of the element in this temporary dimension.

Michel
User avatar
Michel Zijlema
Site Admin
Posts: 712
Joined: Wed May 14, 2008 5:22 am
OLAP Product: TM1, PALO
Version: both 2.5 and higher
Excel Version: 2003-2007-2010
Location: Netherlands
Contact:

Re: Insert Element in Dimension, Set Attribute

Post by Michel Zijlema »

Another option could be to have an alternative hierarchy called 'New elements' in your dimension and add the new elements to this alternative hierarchy. This way you don't need an attribute to flag new elements.

Michel
Duncan P
MVP
Posts: 600
Joined: Wed Aug 17, 2011 1:19 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2
Excel Version: 2003 2007
Location: York, UK

Re: Insert Element in Dimension, Set Attribute

Post by Duncan P »

This is very similar to the problem discussed in this thread http://www.tm1forum.com/viewtopic.php?f=3&t=6669
David Usherwood
Site Admin
Posts: 1458
Joined: Wed May 28, 2008 9:09 am

Re: Insert Element in Dimension, Set Attribute

Post by David Usherwood »

I've used another technique in the past:

a Have a working cube dimensioned by your dimension;
b Fill it with 1s before doing the dimension load;
c Then the elements showing 0 are the new ones.
lotsaram
MVP
Posts: 3698
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Insert Element in Dimension, Set Attribute

Post by lotsaram »

David Usherwood wrote:I've used another technique in the past:

a Have a working cube dimensioned by your dimension;
b Fill it with 1s before doing the dimension load;
c Then the elements showing 0 are the new ones.
This forum should have a hat tip smiley. I'll have to add that one to the play list.
maps
Posts: 43
Joined: Wed Aug 10, 2011 9:21 am
OLAP Product: TM1
Version: 9.4.1 and 9.5.1
Excel Version: 2003

Re: Insert Element in Dimension, Set Attribute

Post by maps »

I had the problem that I have to distinguish between 3 different kind of elements of the dimension.
When I'm imoprting element to the dimension the element can be an "new one" (does not exist yet), "already existing". All other elements of the dimension (elements which are not in the import file are "old ones".

I implemented it now in the following way. I created a new tmp dimension "}blabla" added all the new elements in the metadatatab. The already existing one I could already flag in the metadata tab.

The new ones I flagged in the data tab. For this I iterated over all the elements of my new Dimension and inserted the value of the attribute. To make shure that this procedure is only executed once i used a flag I created in the prolog.

Code: Select all

prolog 
cFlag = 0;

datatab
if(cFlag = 0); 
  cFlag = 1;
    While...
  ENd;
So I was able to flag "new" and "already existing" element. Elements which are not used anymore do not have a entry for the attribute...
Post Reply