Empty alias values

Introduction

Aliases in TM1 are very, very useful. I repeat: very useful. Use them a lot and it will improve your TM1 application without doubt. Alias values can change from time to time, whereas dimension element names will probably not change over time.

For example, an alias can show information in a multi-language model or contain descriptive information when the element name is an ID or account number. Or it can store an abbreviation, or simplify common ETL tasks that would otherwise lead to hard-coding relations in Turbo Integrator.

Adding an alias

Adding an alias is straightforward: let’s say we have a dimension of departments in our company:

The element names are abbreviations, they will likely not change. Then, do a right-mouse click on the name of the dimension in the Server Explorer, choose "Edit element attributes…" and add an attribute from the menu (I called the attribute Full name):

Notice that TM1 by default will fill in the alias values with the same name as the element names:

We are now free to overwrite the values with the names of our liking (or copy/paste from Excel will work too):

Now here’s the problem

The above (in a different context) is what I recently did in a project. I had a requirement to loop over departments and create a view for each of them: the name is the alias value (full name). A simple WHILE … END loop in Turbo Integrator is enough. At the moment of creating the view, I used:

# Wim Gielis # https://www.wimgielis.com
vViewName='Detail for dept ' | Attrs('Department',vDept,'Full name'); ViewCreate(vMyCube,vViewName);

In the above code listing, vDept is the name of the element (department) within the loop. Nothing fancy, all fairly easy. What would be the result? 21 out of 22 views will be created with the expected name (for example, 'Detail for dept customer service'), and one view will be created with the name 'Detail for dept '.

What is going on here?

The problem is the IT department (well, that’s just a coincidence, I swear). As the element name and the alias value for IT are the same, or put differently we did not overwrite the default value of IT with a different name, TM1 does not store this alias value explicitly. It is empty and therefore the variable vViewName shows up as 'Detail for dept ' and no full department name is appended at the end. Yet, what we see and what tricks us here, is the Attributes Editor not showing an empty cell, but rather IT:

And the Subset Editor does show IT, also when we turn on the alias Full name:

So one would clearly expect that asking for the Full name alias value for IT, TM1 would return IT. Nope, it returns an empty string. Where you CAN find the empty value, is in the Control Cube }ElementAttributes_Department:

And the message is …

Be careful! Do not get you trapped the way I did :-) In this particular instance, there was no real damage in the TM1 application, only a view that did not show a correct name. But you would get error messages if more than 1 department would have no alias value: the TI code would try to create a view ('Detail for dept ') that already exists. Rules are also affected: if you test for the value of an attribute using ATTRS, it can happen that the function returns an empty string.

This leads us to 2 possible solutions:

  1. explicitly flll the internal }ElementAttributes control cube;
  2. test the value that is returned by ATTRS. If it is empty, do not use that value but rather the element name.




Homepage

Section contents

About Wim

Wim Gielis is a Business Intelligence consultant and Excel expert

Other links