Matching unnamed subset with named subset

Post Reply
NewtoTM1P
Posts: 5
Joined: Wed Dec 09, 2020 3:42 pm
OLAP Product: TM1
Version: lastest
Excel Version: lastest

Matching unnamed subset with named subset

Post by NewtoTM1P » Sat Feb 20, 2021 4:06 am

I have a total of 100 cubes and 450 cube views in total,
Many cube views are using some Unnamed subset,
and those elements under Unnamed subsets is similar to other elements under the Named subset.
Therefore, I wonder is there anyways to automatically let the cube view use that Named subset that has the same element under the Unnamed subset.?
Any help will be appreciated. Thanks!

tomok
MVP
Posts: 2792
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: Matching unnamed subset with named subset

Post by tomok » Sat Feb 20, 2021 3:54 pm

NewtoTM1P wrote:
Sat Feb 20, 2021 4:06 am
I have a total of 100 cubes and 450 cube views in total,
Many cube views are using some Unnamed subset,
and those elements under Unnamed subsets is similar to other elements under the Named subset.
Therefore, I wonder is there anyways to automatically let the cube view use that Named subset that has the same element under the Unnamed subset.?
Any help will be appreciated. Thanks!
AFAIK, the answer to your question is no. First of all, there is no such thing as an "unnamed subset". Subsets have to have a name, TM1 will not let you create a subset without a name. I think what you are referring to is the situation where someone created a view and manually filtered some of the dimensions contained in that view and then saved the view. In this case, the elements used in the view are actually saved in the .vue file and are not in a subset, i.e., not in a .sub file somewhere. There is no way to way to convert the view into using a named subset, instead of the saved elements, except to re-create the view in a TI process or a user going in and manually doing it.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/

User avatar
Alan Kirk
Site Admin
Posts: 6317
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2 Classic (PAW-free zone)
Excel Version: 2010 and 2016
Location: Sydney, Australia
Contact:

Re: Matching unnamed subset with named subset

Post by Alan Kirk » Sun Feb 21, 2021 6:42 pm

tomok wrote:
Sat Feb 20, 2021 3:54 pm
NewtoTM1P wrote:
Sat Feb 20, 2021 4:06 am
I have a total of 100 cubes and 450 cube views in total,
Many cube views are using some Unnamed subset,
and those elements under Unnamed subsets is similar to other elements under the Named subset.
Therefore, I wonder is there anyways to automatically let the cube view use that Named subset that has the same element under the Unnamed subset.?
Any help will be appreciated. Thanks!
AFAIK, the answer to your question is no. First of all, there is no such thing as an "unnamed subset".
Subsets have to have a name, TM1 will not let you create a subset without a name. I think what you are referring to is the situation where someone created a view and manually filtered some of the dimensions contained in that view and then saved the view. In this case, the elements used in the view are actually saved in the .vue file and are not in a subset, i.e., not in a .sub file somewhere.
I think that's an over-literal definition of what a "subset" is. When you are using MDX you're often working with unnamed subsets, i.e., a list of component elements where the list does not have a name. Even the user interface itself declares the type of subset that you've described as being an "unnamed" subset.
UnnamedSubset.jpg
UnnamedSubset.jpg (50.19 KiB) Viewed 98 times
tomok wrote:
Sat Feb 20, 2021 3:54 pm
There is no way to way to convert the view into using a named subset, instead of the saved elements, except to re-create the view in a TI process
Which means that there IS a way of doing it, but it depends on the reader's definition of "automatic". It can be automated but no, there is no "one click" button to do it. It is not, however, a way that will be quick and easy and determining the value is in the eye of the beholder.

The information about the unnamed subsets will be in the .vue files, as Tomok said. The structure of those files, and how the subsets are stored, is not excessively complex as you can see from the structure below. The .vue files are simply text files. 7 followed by the dimension name tells you you're about to encounter the subset definition, if the next line is 270 followed by a comma and a number then it's the number of elements in the unnamed subset, followed by a list of the elements.
UnnamedSubset2.jpg
UnnamedSubset2.jpg (43.95 KiB) Viewed 98 times
Reading and parsing that file to extract a list of the elements would not be a huge task if you have access to the database directory, and a decent programming language at your disposal.

If you don't have access to the data directory it could still be done with TI since obviously the server itself has access to its data directory. The problem there is that I said "a decent programming language" whereas TI is the programming language equivalent of a stone axe. Still, it could be done.

Then you would need to compare the extracted list with your named subsets to find a match. Again, easy with a decent language, less easy with a stone axe.

Having done that you could then use either TI or the REST API to redefine the views using the equivalent named subset.

Python may be an option, but if you don't know Python then there's an extra learning curve. If you don't know the REST API, that's another one.

Could you do it entirely in TI? Sure, it would be possible. You'd probably need to create temporary cubes or dimensions to store the extracted element lists, and it would take a LOT of coding (your value of "a lot" may vary), but in theory it's possible. It just depends on how much value the project would have for you.

I've never done something like this myself, and have neither the time nor inclination to do so at this point, but the tools available to you certainly make it possible. (Actually it may well be a fun "exploration" project, so just make that "the time".)

If you have hundreds of views then maybe it's worth your time, especially since once you've done it you can reuse it in the future. However note that this will only work for public views, not private ones. (With private ones the only way I can see it being done is by hacking the .vue text file so that the new view applies the next time the user logs in. While I admit to having done this on occasion in very particular circumstances, altering system files is not something that I can officially recommend.)
"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
Harvey
Community Contributor
Posts: 224
Joined: Mon Aug 04, 2008 4:43 am
OLAP Product: PA, TM1, CX, Palo
Version: TM1 8.3 onwards
Excel Version: 2003 onwards
Contact:

Re: Matching unnamed subset with named subset

Post by Harvey » Mon Feb 22, 2021 5:06 am

Agree with Alan's post, with one exception. You used the following language:
NewtoTM1P wrote:
Sat Feb 20, 2021 4:06 am
those elements under Unnamed subsets is similar to other elements under the Named subset.
Similar or the same? It would be much harder to detect "similar" subsets than identical ones.

One could imagine an algorithm where you could match an unnamed subset with a subset that contains all of its elements and maybe a percentage more, but that might get tricky, as it would change the shpe of some views and might break dependencies.

Your main problem is that TI provides no native way to read properties that make up a view. IE There is no "ViewColumnDimensionGet", only a "ViewColumnDimensionSet".

This has always been a slightly confounding issue when writing generic utility functions for views, and the same would apply to your task -- you just can't "look" at a view in code and alter what you see.

As Alan said, you'd have to read the individual lines of the .vue file in the data folder to get that information. For completeness, you'd probably also need to throw in some error handling for views created with MDX -- I've never even examined a .vue file for an MDX view. I'm sure it looks quite different from an oldskool .vue.

I would suggest it's not for the faint of heart. Would love to see the solution if you come up with one.

PS: Once you've cleaned this up, I'd suggest implementing a best practice policy that doesn't allow the creation of public views with unnamed subsets at all. That's how I've handled this on most of my projects for the past few years.
Take your TM1 experience to the next level - TM1Innovators.net

User avatar
ykud
MVP
Posts: 130
Joined: Sat Jan 10, 2009 10:52 am
Contact:

Re: Matching unnamed subset with named subset

Post by ykud » Mon Feb 22, 2021 7:03 am

I'd say it's probably simpler with rest api than with a TI over .vue files, but I'm biased as I had to do something similar to identify all the views that had the unnamed ALL subset in their definition.
Here's the script I used:
https://github.com/ykud/tm1_restapi/blo ... e_views.py

User avatar
Harvey
Community Contributor
Posts: 224
Joined: Mon Aug 04, 2008 4:43 am
OLAP Product: PA, TM1, CX, Palo
Version: TM1 8.3 onwards
Excel Version: 2003 onwards
Contact:

Re: Matching unnamed subset with named subset

Post by Harvey » Mon Feb 22, 2021 9:45 pm

ykud wrote:
Mon Feb 22, 2021 7:03 am
I'd say it's probably simpler with rest api than with a TI over .vue files
Definitely, if you have the skillset.
Take your TM1 experience to the next level - TM1Innovators.net

Post Reply