Hi Guys,
I have been dipping my toe in to the world of MDX after going through the excellent documentation posted on this forum. (Many thanks Philip.) Basically I am trying to find any outlet code that starts L0, L1, L2, L3, L4, L5, L6, L7, L8 or L9. I have done this within the subset editor for now and I have created the following code:
{TM1SORT({UNION(
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l0*")},
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l1*")},
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l2*")},
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l3*")},
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l4*")},
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l5*")},
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l6*")},
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l7*")},
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l8*")},
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l9*")})}
,ASC)}
I have tried changing things round a bit to try and get it working but I have had no success. Is my problem that UNION only works in TI or is my first stab at code got errors in?
Can anyone help?
Cheers,
Jim.
MDX Question
- jim wood
- Site Admin
- Posts: 3958
- Joined: Wed May 14, 2008 1:51 pm
- OLAP Product: TM1
- Version: PA 2.0.7
- Excel Version: Office 365
- Location: 37 East 18th Street New York
- Contact:
MDX Question
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
-
- Posts: 42
- Joined: Mon May 19, 2008 10:25 am
- OLAP Product: TM1, EV
- Version: 9.0 9.1 9.4 9.5 10.1 10.2
- Excel Version: 2003 2007 2010 2015
- Location: London, UK
Re: MDX Question
Not that I am in any way proficient with MDX, but I think that your example will only do a UNION between the first two statements, if at all
I would either try to limit the FILTERBYPATTERN to look for anything that starts with an "l" or try the following
Incase I have typed this incorrectly - I am doing a UNION join with the result of the preceeding join
(I am sure that someone has a far better way of doing this - always ready to learn)
I would either try to limit the FILTERBYPATTERN to look for anything that starts with an "l" or try the following
Code: Select all
TM1SORT(
UNION(
UNION(
UNION(
UNION(
UNION(
UNION(
UNION(
UNION(
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l0*")},
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l1*")}),
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l2*")}),
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l3*")}),
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l4*")}),
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l5*")}),
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l6*")}),
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l7*")}),
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l8*")}),
{TM1FILTERBYPATTERN( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [taps outlet] )}, 0)}, "l9*")}
)
,ASC)
(I am sure that someone has a far better way of doing this - always ready to learn)
Anthony
That's no moon - that's a space station
That's no moon - that's a space station
- jim wood
- Site Admin
- Posts: 3958
- Joined: Wed May 14, 2008 1:51 pm
- OLAP Product: TM1
- Version: PA 2.0.7
- Excel Version: Office 365
- Location: 37 East 18th Street New York
- Contact:
Re: MDX Question
I think I get what you mean. It sounds to me like UNION is the new IF!
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
- jim wood
- Site Admin
- Posts: 3958
- Joined: Wed May 14, 2008 1:51 pm
- OLAP Product: TM1
- Version: PA 2.0.7
- Excel Version: Office 365
- Location: 37 East 18th Street New York
- Contact:
Re: MDX Question
Within the definition of UNION on MSDN I found the following: "This function returns the union of two or more specified sets."
This would tend to suggest that you can bring together multiple sets and you are not limited to 2. Is any limitation due to TM1 compatibility issues?
This would tend to suggest that you can bring together multiple sets and you are not limited to 2. Is any limitation due to TM1 compatibility issues?
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
- Renaud MARTIAL
- Posts: 25
- Joined: Thu May 15, 2008 10:18 am
- Location: Paris, France
Re: MDX Question
Hello,
I think you don't have to use 'union'. Just add members between {}, separated by a comma.
Try the following
Regards,
Renaud.
I think you don't have to use 'union'. Just add members between {}, separated by a comma.
Try the following
Code: Select all
TM1SORT(
TM1FilterByLevel(
{ TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L0*") ,
TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L1*") ,
TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L2*") ,
TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L3*") ,
TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L4*") ,
TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L5*") ,
TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L6*") ,
TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L7*") ,
TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L8*") ,
TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L9*")
}
, 0 )
, ASC )
Renaud.
- jim wood
- Site Admin
- Posts: 3958
- Joined: Wed May 14, 2008 1:51 pm
- OLAP Product: TM1
- Version: PA 2.0.7
- Excel Version: Office 365
- Location: 37 East 18th Street New York
- Contact:
Re: MDX Question
That worked a treat. Thanks for your help guys.Renaud MARTIAL wrote:Hello,
I think you don't have to use 'union'. Just add members between {}, separated by a comma.
Try the followingRegards,Code: Select all
TM1SORT( TM1FilterByLevel( { TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L0*") , TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L1*") , TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L2*") , TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L3*") , TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L4*") , TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L5*") , TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L6*") , TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L7*") , TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L8*") , TM1FilterByPattern( {TM1SUBSETALL( [taps outlet] )}, "L9*") } , 0 ) , ASC )
Renaud.
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
- Steve Vincent
- Site Admin
- Posts: 1054
- Joined: Mon May 12, 2008 8:33 am
- OLAP Product: TM1
- Version: 10.2.2 FP1
- Excel Version: 2010
- Location: UK
Re: MDX Question
i think you'll find UNION has to be the first thing in the MDX, i've used it quite sucessfully in MDX as in the following;
Code: Select all
{UNION (
{FILTER (
{TM1SUBSETALL( [Ops Plan OBS] )}
, ([ops plan].([Version].[Current Prog Req Supp], [Ops Plan Measures].[Ops Plan Headcount]))
- ([ops plan].([Version].[Current Agreed Sol], [Ops Plan Measures].[Ops Plan Headcount]))
> [ops plan].([Version].[Current Prog Req Supp], [Ops Plan Measures].[Ops Plan Headcount]) * 0.01
)}
,
{FILTER (
{TM1SUBSETALL( [Ops Plan OBS] )}
, ([ops plan].([Version].[Current Agreed Sol], [Ops Plan Measures].[Ops Plan Headcount]))
- ([ops plan].([Version].[Current Prog Req Supp], [Ops Plan Measures].[Ops Plan Headcount]))
> [ops plan].([Version].[Current Prog Req Supp], [Ops Plan Measures].[Ops Plan Headcount]) * 0.01
)}
)}
If this were a dictatorship, it would be a heck of a lot easier, just so long as I'm the dictator.
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet