Automatically update time dimension

Post Reply
i.iescone
Posts: 2
Joined: Sun Jan 15, 2023 5:24 pm
OLAP Product: TM1
Version: 2.0.9.12
Excel Version: excel365

Automatically update time dimension

Post by i.iescone »

Hello everyone, I'm a starter in tm1 and I'd like to set up a chore that update the time dimension uploading all the months of the current year plus the first three months of the next one

So far this is my code..which doesn't work on a dummy dimension I used as data source. What do you suggest to go on with?


#Section Prologo

#****Begin: Generated Statements***

#****End: Generated Statements****

dimTempo='Time';

currentyear='2022';

nextyear='2023';



#Section Metadata

#****Begin: Generated Statements***

#****End: Generated Statements****



#Section Dati

#****Begin: Generated Statements***

#****End: Generated Statements****



i=1;

elemento= DIMNM( dimTempo, i );

while(DIMIX( dimTempo, elemento )=0);



if( DimensionElementExists( dimTempo, elemento )=1 );

DimensionElementDelete( dimTempo, elemento );

endif;



DimensionElementInsert( dimTempo, '', 'currentyear', 'C' );

DimensionElementComponentAdd( dimTempo, 'currentyear', '01|.|currentyear', 1 );

DimensionElementComponentAdd( dimTempo, 'currentyear', '02|.|currentyear', 1 );

DimensionElementComponentAdd( dimTempo, 'currentyear', '03|.|currentyear', 1 );

DimensionElementComponentAdd( dimTempo, 'currentyear', '04|.|currentyear', 1 );

DimensionElementComponentAdd( dimTempo, 'currentyear', '05|.|currentyear', 1 );

DimensionElementComponentAdd( dimTempo, 'currentyear', '06|.|currentyear', 1 );

DimensionElementComponentAdd( dimTempo, 'currentyear', '07|.|currentyear', 1 );

DimensionElementComponentAdd( dimTempo, 'currentyear', '08|.|currentyear', 1 );

DimensionElementComponentAdd( dimTempo, 'currentyear', '09|.|currentyear', 1 );

DimensionElementComponentAdd( dimTempo, 'currentyear', '10|.|currentyear', 1 );

DimensionElementComponentAdd( dimTempo, 'currentyear', '11|.|currentyear', 1 );

DimensionElementComponentAdd( dimTempo, 'currentyear', '12|.|currentyear', 1 );



DimensionElementInsert( dimTempo, '', 'nextyear', 'C' );

DimensionElementComponentAdd( dimTempo, 'nextyear', '01|.|nextyear', 1 );

DimensionElementComponentAdd( dimTempo, 'nextyear', '02|.|nextyear', 1 );

DimensionElementComponentAdd( dimTempo, 'nextyear', '03|.|nextyear', 1 );



i=i+1;

end;
User avatar
gtonkin
MVP
Posts: 1261
Joined: Thu May 06, 2010 3:03 pm
OLAP Product: TM1
Version: Latest and greatest
Excel Version: Office 365 64-bit
Location: JHB, South Africa
Contact:

Re: Automatically update time dimension

Post by gtonkin »

A couple of things here but the main one is that your apostrophe should be after the month number and before the pipe, not after the year.

Edit: Also best to do meta data updates in meta data otherwise you may rather want to look at the Direct commands for your inserts.
BR, George.

Learn something new: MDX Views
Wim Gielis
MVP
Posts: 3233
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Automatically update time dimension

Post by Wim Gielis »

Hello, do you have access to a training course on TM1 ? Or qualified coworkers ?
This will be valuable I think to grasp the basics.
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Post Reply