SubsetElementExists, Aliases and Principal Names

Post Reply

Is this a bug?

Yes. It needs to be drowned in Mortein
6
86%
No. I'm sure that IBM had a good reason for doing it that way. And failing to document it.
0
No votes
I don't know. Who knows WHAT goes on inside the collective head of IBM?
1
14%
 
Total votes: 7

User avatar
Alan Kirk
Site Admin
Posts: 6606
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

SubsetElementExists, Aliases and Principal Names

Post by Alan Kirk »

I'm not sure whether this should be treated as a bug (at least in my version; PA 2.0.6 at the time of writing), or just something to be aware of. (I know which one IBM would regard it as being; after all, "support" is mostly a way for us to pay money, not to get anything fixed.)

The short version is that in my version SubsetElementExists only seems to work if you pass it the element's principal name, not an alias. (This is regardless of whether that alias is on the subset.) I've never noticed this before because most of the time I DO only work with the principal name when creating subsets, but today I was using an alias to add the elements. I checked whether the element was in the subset using the same value to make sure I wasn't adding it multiple times as the loops executed. Gee, imagine my surprise when it was added 38 times because it supposedly wasn't already in the subset. Finally I figured out what's going on.

Take the following example; a dimension of countries with principal names in English and an alias of NomeItaliano which shows the names in Italian.
Countries2.jpg
Countries2.jpg (83.9 KiB) Viewed 1244 times
OK, now consider this code where I use the NomeItaliano attribute to punch the elements into a subset named ItalianSpeakingCountries. I then check the existence of the elements in the subset using the same aliases that I used to insert them:

Code: Select all

sLogFile = 'NOAlias.txt';

sDimName = 'Countries';
sSubName = 'ItalianSpeakingCountries';
If (SubsetExists(sDimName, sSubName) <> 0);
  SubsetDestroy(sDimName, sSubName);
Endif;
SubsetCreate(sDimName, sSubName, 0);

sAlias = '';
# sAlias = 'NomeItaliano';

# In this one, I do NOT assign an alias to the subset.
# SubsetAliasSet(sDimName, sSubName, 'NomeItaliano');

SubsetElementInsert( sDimName, sSubName, 'Italia', 1);
SubsetElementInsert( sDimName, sSubName, 'Svizzera', 2);
SubsetElementInsert( sDimName, sSubName, 'San Marino', 3);

AsciiOutput(sLogFile, Expand('The subset %sSubName% has been created in the dimension %sDimName%, with an alias of "%sAlias%".'));

iElement = 1; iElementMax = 4;

While( iElement <= iElementMax);

  If ( iElement = 1 );
    sElement = 'Italia';
  ElseIf ( iElement = 2 );
    sElement = 'Italy';
  ElseIf ( iElement = 3 );
    sElement = 'Svizzera';
  ElseIf ( iElement = 4 );
    sElement = 'Switzerland';
  EndIf;

  iCheck = SubsetElementExists( sDimName, sSubName, sElement);

  If( iCheck = 0);
    sMsg = Expand('The element %sElement% is NOT in the subset %sSubName%.');
  Else;
      sMsg = Expand('The element %sElement% IS in the subset %sSubName%.');
  EndIf;

  AsciiOutput(sLogFile, sMsg );

  iElement = iElement + 1;
End;
Now, the subset itself is exactly what I would expect; no alias, with the elements that I inserted - albeit the principal names of those elements:
CountriesSubsetNoAlias.jpg
CountriesSubsetNoAlias.jpg (59.7 KiB) Viewed 1244 times
Now check what came out in the log file:

Code: Select all

"The subset ItalianSpeakingCountries has been created in the dimension Countries, with an alias of ""."
"The element Italia is NOT in the subset ItalianSpeakingCountries."
"The element Italy IS in the subset ItalianSpeakingCountries."
"The element Svizzera is NOT in the subset ItalianSpeakingCountries."
"The element Switzerland IS in the subset ItalianSpeakingCountries."
Even though I added the alias Italia, that alias is NOT reported as being part of the subset; only the principal name Italy is. The same with Svizzera rather than Switzerland. Yes, true, I've observed previously that despite Italian being one of the 4 official languages of Switzerland, the only people who speak it north of Lugarno are me (if I happen to be visiting) and reruns of Il commissario Montalbano. However I don't think that's the cause of this problem.

If I change the code slightly to add the alias to the subset, then:

Code: Select all

sLogFile = 'HASAlias.txt';

sDimName = 'Countries';
sSubName = 'ItalianSpeakingCountries';
If (SubsetExists(sDimName, sSubName) <> 0);
  SubsetDestroy(sDimName, sSubName);
Endif;
SubsetCreate(sDimName, sSubName, 0);

#sAlias = '';
sAlias = 'NomeItaliano';

# In this one, I DO assign an alias to the subset.
SubsetAliasSet(sDimName, sSubName, sAlias);

SubsetElementInsert( sDimName, sSubName, 'Italia', 1);
SubsetElementInsert( sDimName, sSubName, 'Svizzera', 2);
SubsetElementInsert( sDimName, sSubName, 'San Marino', 3);

AsciiOutput(sLogFile, Expand('The subset %sSubName% has been created in the dimension %sDimName%, with an alias of "%sAlias%".'));

iElement = 1; iElementMax = 4;

While( iElement <= iElementMax);

  If ( iElement = 1 );
    sElement = 'Italia';
  ElseIf ( iElement = 2 );
    sElement = 'Italy';
  ElseIf ( iElement = 3 );
    sElement = 'Svizzera';
  ElseIf ( iElement = 4 );
    sElement = 'Switzerland';
  EndIf;

  iCheck = SubsetElementExists( sDimName, sSubName, sElement);

  If( iCheck = 0);
    sMsg = Expand('The element %sElement% is NOT in the subset %sSubName%.');
  Else;
      sMsg = Expand('The element %sElement% IS in the subset %sSubName%.');
  EndIf;

  AsciiOutput(sLogFile, sMsg );

  iElement = iElement + 1;
End;
So here's the newly recreated subset WITH its alias:
CountriesSubsetWithAlias.jpg
CountriesSubsetWithAlias.jpg (56.34 KiB) Viewed 1244 times
Buuuut.... here's the log:

Code: Select all

"The subset ItalianSpeakingCountries has been created in the dimension Countries, with an alias of "NomeItaliano"."
"The element Italia is NOT in the subset ItalianSpeakingCountries."
"The element Italy IS in the subset ItalianSpeakingCountries."
"The element Svizzera is NOT in the subset ItalianSpeakingCountries."
"The element Switzerland IS in the subset ItalianSpeakingCountries."
It still doesn't recognise the alias names as being part of the subset, it still only recognised the principal names.

Needless to say, the official IBM Reference Page for SubsetElementExists makes absolutely no bloody reference to this, although they will probably claim that "it's because, um, ah, we designed it that way and it's not our stwategy to change it."

Anyway, hopefully this will save someone else the amount of time that I wasted today on this.

I turn it over to you to decide whether I should throw it in as a bug ticket.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
MarenC
Regular Participant
Posts: 346
Joined: Sat Jun 08, 2019 9:55 am
OLAP Product: Planning Analytics
Version: Planning Analytics 2.0
Excel Version: Excel 2016

Re: SubsetElementExists, Aliases and Principal Names

Post by MarenC »

Hi,

Is it a bug? Hmmmmmmmm. Not sure.

I only say not sure because the issue would only really be relevant to developers. And as long as they are aware of it I guess they can code for it.

It would be a 100% bug if the 'normal' users were ever presented with a message saying Italia does not belong in the subset ItalianSpeakingCountries.

Maren
User avatar
Alan Kirk
Site Admin
Posts: 6606
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: SubsetElementExists, Aliases and Principal Names

Post by Alan Kirk »

MarenC wrote: Tue Mar 29, 2022 7:48 am It would be a 100% bug if the 'normal' users were ever presented with a message saying Italia does not belong in the subset ItalianSpeakingCountries.
But they could. For example, if they were running a TI process via an action button, and the TI checked that an element was in a subset. This isn't merely hypothetical because it was part of what I was developing.

And yes, developers can code for it if they know about it... but I'll lay odds that many don't, resulting in wasted time and effort. I did leave a comment on the IBM documentation pointing out that this should be documented... but it's probably not their stwategy to fix their documentation. (And I can think of many instances where the documentation has been bad for years, and remains so to this day.)
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
User avatar
Steve Rowe
Site Admin
Posts: 2410
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: SubsetElementExists, Aliases and Principal Names

Post by Steve Rowe »

On the basis the Member ID / EPN and their respective aliases are always totally interchangable 100% of the time, this is a bug.

It is probably behaving as deisgned however....
Technical Director
www.infocat.co.uk
Post Reply