DimensionElementInsertByAlias and DimensionEditingAliasSet

Post Reply
Wim Gielis
MVP
Posts: 2912
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.10
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

DimensionElementInsertByAlias and DimensionEditingAliasSet

Post by Wim Gielis »

Hi all,

I know this function is undocumented. Still a bit curious about the usage and parameters.

This code works and inserts an element called 'Hotel costs' into the dimension:

Code: Select all

DimensionElementInsertByAlias( 'PL_Account', '', 'test', 'Hotel costs', 'N' );
However, the 3rd argument should not be empty. The process does not throw an error but nothing happens in that case.

No idea where the alias part comes in.

I started dabbling around with this function, hoping it would have some link to this topic: viewtopic.php?f=3&t=15994

If anyone has found more about this function, please post :D
Last edited by Wim Gielis on Sun Jun 26, 2022 3:10 pm, edited 1 time in total.
Best regards,

Wim Gielis

Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 120 TM1 articles and a lot of custom code
Newest blog article: Documenting processes and rules https://github.com/wimgielis
Wim Gielis
MVP
Posts: 2912
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.10
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: DimensionElementInsertByAlias and DimensionEditingAliasSet

Post by Wim Gielis »

After more detailed investigations together with George Tonkin, below is what we suppose to be the (limited) use case.

First you use the (undocumented) function DimensionEditingAliasSet to pick an existing alias from a dimension.
That alias will receive (meaningful) names of new elements that are added to the dimension, with the function DimensionElementInsertByAlias.

However, you care about the alias values but you do not (necessarily) care at all about the names of the new elements.
They could be dummy element names with an incrementing suffix.

That is what DimensionElementInsertByAlias does :)

Consider this example. You have a bunch of company names:
  • Thiel-Brekke
  • McKenzie, McKenzie and Labadie
  • Smitham, Brakus and Flatley
  • Kihn-Huels
  • Leffler-Gaylord
  • Leffler and Sons
  • Hand PLC
  • Marvin-Haley
  • Smitham, Rau and Greenfelder
  • Becker, Bode and Sporer
  • Kuhic Inc
  • Rempel-Nader
  • Quitzon, Moen and Nienow
  • Ortiz-Carroll
  • Doyle Inc
  • Fisher-Kertzmann
  • Spencer-Cruickshank
  • Ullrich-Nienow
  • Larkin-Lueilwitz
  • Jacobi Inc
But you don't want them to be element principal names because you want to easily change the names.
Still you are confident that no duplicate alias values will exist.

Then this code can be run (or you use a data source rather then all Prolog tab code):

Code: Select all

DimensionEditingAliasSet( 'Company', 'Description' );

DimensionElementInsertByAlias( 'Company', '', 'Thiel-Brekke', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'McKenzie, McKenzie and Labadie', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Smitham, Brakus and Flatley', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Kihn-Huels', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Leffler-Gaylord', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Leffler and Sons', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Hand PLC', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Marvin-Haley', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Smitham, Rau and Greenfelder', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Becker, Bode and Sporer', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Kuhic Inc', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Rempel-Nader', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Quitzon, Moen and Nienow', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Ortiz-Carroll', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Doyle Inc', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Fisher-Kertzmann', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Spencer-Cruickshank', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Ullrich-Nienow', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Larkin-Lueilwitz', 'Comp', 'N' );
DimensionElementInsertByAlias( 'Company', '', 'Jacobi Inc', 'Comp', 'N' );
Result:
hln.PNG
hln.PNG (29.99 KiB) Viewed 6964 times
"Comp" is the common part that is prefixing an underscore character and an incrementing number.
You don't need to store 19 as the last index. Adding a new company name with:

Code: Select all

DimensionEditingAliasSet( 'Company', 'Description' );
DimensionElementInsertByAlias( 'Company', '', 'IBM', 'Comp', 'N' );
gives you:
hln_2.PNG
hln_2.PNG (6.48 KiB) Viewed 6964 times
Note that:

- You need to provide an existing alias attribute
- Architect / Perspectives allow to save the process, PAW does not and you will be confronted with a sea of red squiggles. It's up to you whether you want that or not, besides the fact that these functions are undocumented but exist for a very long time in TM1.
hln_3.PNG
hln_3.PNG (32.78 KiB) Viewed 6964 times
It seems that the use case could be: generate dummy/placeholder elements in a dimension to store real element names in a chosen alias.
TM1 will remember the last index used and create the suffix for you, you don't need to maintain what is the last index (which can differ by anything that precedes the suffix). You have the flexibility (and power) of alias values such that users can easily change them. At the same time you don't care about the corresponding element names.

You can insert the same names multiple times. TM1 will not add them multiple times and will also not send minor or major errors. Nothing happens for these elements.

The last but one argument to the function cannot be empty. No error message but nothing happens.

What do you think: useful or not ?
Best regards,

Wim Gielis

Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 120 TM1 articles and a lot of custom code
Newest blog article: Documenting processes and rules https://github.com/wimgielis
MarenC
Regular Participant
Posts: 225
Joined: Sat Jun 08, 2019 9:55 am
OLAP Product: Planning Analytics
Version: Planning Analytics 2.0
Excel Version: Excel 2016

Re: DimensionElementInsertByAlias and DimensionEditingAliasSet

Post by MarenC »

Hi,

very useful to know this exists., and that you have finally found a decent use case :lol:

This could save lots of code when adding in say, dummy employees into a dimension.

However, I am not sure if I want to lose control over doing that.

For example, what happens if you delete Comp_2 as an element, will it insert Comp_2 and then add in Comp_21 the next time this is run?
Or does it create Comp_21 and Comp_22?

Also, does dimensionelementcomponentadd work as normal with this?

Maren
Wim Gielis
MVP
Posts: 2912
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.10
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: DimensionElementInsertByAlias and DimensionEditingAliasSet

Post by Wim Gielis »

TM1 will create Comp_2 and Comp_20. So filling up the gaps first.

Adding elements works fine too:

DimensionEditingAliasSet( 'Company', 'Description' );
DimensionElementInsertByAlias( 'Company', '', 'Aexis international', 'Comp', 'C' );
DimensionElementComponentAdd( 'Company', 'Aexis International', 'IBM', 1 );
tm1.PNG
tm1.PNG (23.65 KiB) Viewed 6844 times
Best regards,

Wim Gielis

Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 120 TM1 articles and a lot of custom code
Newest blog article: Documenting processes and rules https://github.com/wimgielis
MarenC
Regular Participant
Posts: 225
Joined: Sat Jun 08, 2019 9:55 am
OLAP Product: Planning Analytics
Version: Planning Analytics 2.0
Excel Version: Excel 2016

Re: DimensionElementInsertByAlias and DimensionEditingAliasSet

Post by MarenC »

Hi,

This is interesting and worth being aware of, certainly an option.

The biggest problem I can see with this is that it adds 1, 2, 3, 4 to the end. But what if we want to add Comp000001, Comp000002, Comp00003...Comp000010 etc etc.

If this had a fill parameter it would be great.

Also, we often want the aliases to include the element name, so Comp_01 - IBM or IBM - Comp_01 for example. Can this method allow for that?

Maren
Post Reply