DimensionElementComponentAdd issue

Post Reply
Wim Gielis
MVP
Posts: 3240
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:

DimensionElementComponentAdd issue

Post by Wim Gielis »

Hello all,

I have a strange situation in TI with a very simple dimension, simplying further is not possible.

This code in the Prolog gives an error on the line with DimensionElementInsert, saying that the element that I want to insert already exists as an alias. This is correct.
But if I comment out the DimensionElementComponentAdd code, the Dtype function is honoured and the code continues without error (and does not try to insert the element).

Code: Select all

DimensionElementComponentAdd( 'dim', 'Total', 'A', 1 );

If( Dtype( 'dim', 'd' ) @<> 'N' );
 DimensionElementInsert( 'dim', '', 'd', 'N' );
EndIf;
Howcome......... ?

I know that using Dimix = 0 would be better than Dtype @<> 'N' but still, why does this happen ?
00.PNG
00.PNG (76.68 KiB) Viewed 2771 times
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
User avatar
gtonkin
MVP
Posts: 1265
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: DimensionElementComponentAdd issue

Post by gtonkin »

Hi Wim,
From what I can see using a quick asciioutput, it looks like an inconsistent behaviour with the temporary dimension.
If you make a change to the dimension, the temporary dimension is created and used for the Prolog changes. The DType does not seem to resolve d=c and thus DType=N.
An ATTRS('dim','d','alias_1'); does however resolve to c which in turn returns d.
Moving the DimensionElementComponentAdd below the IF(DType...) section is as good as hashing it i.e. temporary dimension not created yet.
Setting a variable to the principal name e.g. sEl=DimensionElementPrincipalName('dim','d'); and then using sEl in the DType function seems to get around this.
Looks like you have discovered an obscure bug though as other functions behave as expected.
BR, George.

Learn something new: MDX Views
Wim Gielis
MVP
Posts: 3240
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: DimensionElementComponentAdd issue

Post by Wim Gielis »

Hello George,

Thank you for investigating.

In fact, originally, the code was put in the Metadata tab.
So reversing the statemens would help for the first record (ODBC table is the data source), but not for any subsequent records.
In fact, it was reversed originally, and then I saw that the Dtype = N is taken for the first record, and for any record where that dimension element occurs again.
Say a cost center that occurs 10 times in the data load, then 10 records are "fine" and all other do not get Dtype = N, even though these costcenters exist as alias values.

The background of this case is that the cost centers in the table were the element names in TM1, and the process always ran fine.
For unknown reasons, the table offered the alias values to TM1, not the element names anymore. Then I saw this issue coming up.
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