Page 1 of 1
TM1TupleSize function
Posted: Thu Jul 14, 2016 9:01 pm
by PavoGa
How does this function work and how would one use it? I have been unable to find an example of its usage.
Re: TM1TupleSize function
Posted: Fri Jul 15, 2016 12:43 pm
by PavoGa
Got word that IBM has never even had a support call on it. So either I am a complete idiot and cannot comprehend the
Reference Guide entry on it or no one uses it.

Re: TM1TupleSize function
Posted: Fri Jul 15, 2016 7:16 pm
by Wim Gielis
Hello Ty,
I don't find it a difficult function, even with limited documentation. But I have to admit that I don't know a lot of good uses for the function.
Here's an example with 2 dimensions. Say you have a Line dimension to capture input by the user. It has 100 elements, of which only a limlited number should show up for the user.
Below are the first 10 elements.

- 01.PNG (27.8 KiB) Viewed 4053 times
Then you have an Item dimension, containing elements:

- 02.PNG (20.61 KiB) Viewed 4053 times
You would like to filter the Lines to show the first 4 input lines, because you have 4 items in the dimension:

- 03.PNG (49.34 KiB) Viewed 4053 times
That might be one example.
Re: TM1TupleSize function
Posted: Fri Jul 15, 2016 8:23 pm
by Trevor MacPherson
Not sure I can imagine a lot of practical applications for TM1TupleSize (that aren't better served by the default behavior of other functions), but it "works" as far as I can tell.
It expects a tuple, and I think many of us more commonly work with sets, so that may throw some people of. To get a tuple from a set, you just need to specify the item in the collection.
Set:
{FILTER( {TM1SUBSETALL( [Weekly Performance] )}, [Weekly Performance].[enddate] < 20635)}
i.e. periods which end before July 1, 2016 (or June 29, 1956 depending on how you created your dates).
Tuple - for first item in the collection (set)
{FILTER( {TM1SUBSETALL( [Weekly Performance] )}, [Weekly Performance].[enddate] < 20635)}.Item(0)
- now, if you were to use this as a dynamic subset, it will fail to compile, because it is a tuple, not a set.
To convert it to a set:
{{FILTER( {TM1SUBSETALL( [Weekly Performance] )}, [Weekly Performance].[enddate] < 20635)}.Item(0)}
So, how might one use TM1TupleSize? The only thing I can imagine is to validate a set before creating it, possibly when creating from TI (i.e. to avoid "Unable to register Subset...", for which there are other, more common workarounds.
It could be something like - if there are no members in this, then show that ... the following is highly contrived, but:
If I have periods in my time dimension with end dates before July 1st, then populate my version dimension subset with "Actual", otherwise use "Forecast" (items 2 and 3 in my subset respectively)
{{TM1SUBSETALL( [Version] )}.Item(IIF(TM1TupleSize({FILTER( {TM1SUBSETALL( [Weekly Performance] )}, [Weekly Performance].[enddate] < 20635)}.Item(0))=0,2,3))}
Someone more creative than me can likely come up with better uses, but in any case, it does function, and return a 0 for tuples which don't exist.
Re: TM1TupleSize function
Posted: Fri Jul 15, 2016 8:52 pm
by PavoGa
Thank you, both.
So, how might one use TM1TupleSize? The only thing I can imagine is to validate a set before creating it, possibly when creating from TI (i.e. to avoid "Unable to register Subset...", for which there are other, more common workarounds.
Trevor, that is the only thing I had thought of and, as you point out, there are more common methods.
I was just doing work on some MDX subsets and saw it. Not being sure of exactly what it did and how it worked, figured fishing for innovative uses of it would not hurt.
Thanks again, guys.
Ty