Using parameters in MDX (subset editor)

Post Reply
Marioler
Posts: 12
Joined: Tue Feb 26, 2013 10:08 am
OLAP Product: TM1
Version: PA local 2.0.8
Excel Version: 2016

Using parameters in MDX (subset editor)

Post by Marioler »

Hi Guys

I wonder if it is possible to use parameters (e.g. a value from a parameter cube) in a MDX statement in the subset editor's expression window (not in an active form in excel - I know how to do it there).

Example:
Children of element "123" in dimension "CostCenter".
MDX: {[CostCenter].[123].children}
Question: Is it possible to get "123" as a parameter from another cube?

If the MDX is used in an active form in an excel report it would be no problem to get the value "123" using a DBR function and then referring to that cell in the MDX. But I don't know how I can solve it in the subset editor's expression window directly.

I checked this document called "MDX primer" but could not find an answer to this question.

Thanks for your help.
Mario
EvgenyT
Community Contributor
Posts: 324
Joined: Mon Jul 02, 2012 9:39 pm
OLAP Product: TM1
Version: PAL 2.0.8
Excel Version: 2016
Location: Sydney, Australia

Re: Using parameters in MDX (subset editor)

Post by EvgenyT »

As far as Mdx primer goes: Using parameters in queries, page 26

In your example: something along this ways ...

{tm1filterbypattern ({tm1subsetall([cost centre])},[CubeName].(strToMember("[First Dim].[Element]"),[Second Dim].[Element] )) }

That will pull that cost centre from another cube...

see if you can work out how to use TM1SubsetToSet after you get that cost centre ;) Let me know how you go, will be happy to assist further


Thanks

Evgeny
tomok
MVP
Posts: 2836
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: Using parameters in MDX (subset editor)

Post by tomok »

Marioler wrote:I checked this document called "MDX primer" but could not find an answer to this question.
How about this section in the document http://www.bihints.com/using_parameters_in_queries? Seems spot on in my opinion.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
Marioler
Posts: 12
Joined: Tue Feb 26, 2013 10:08 am
OLAP Product: TM1
Version: PA local 2.0.8
Excel Version: 2016

Re: Using parameters in MDX (subset editor)

Post by Marioler »

Hi

Thank you very much for your help guys! It works now.

I finally found the last step in the section called "Using TM1 Subsets, TM1Member, TM1SubsetToSet and Item" in the MDX primer. with the following example:
{FILTER( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [Account] )}, 1)}, [Reconciliation].([Entity].[All Entities],TM1Member([Date].[Current Date].Item(0),0),[Reconciliation Measures].[Transaction Balance]) <> 0 )}"

That in combination with your answers made it possible for me to solve it.
Thanks again!
jdeberardis
Posts: 8
Joined: Wed Dec 15, 2010 12:42 am
OLAP Product: TM1
Version: 9.4.x
Excel Version: 2007

Re: Using parameters in MDX (subset editor)

Post by jdeberardis »

hi Guys,

Very sorry to necro an old thread but it is the closest one i've found that is close to my question.

I've been trying to wrap my head around it all day and cannot work it out.

Code: Select all

{
    FILTER(
        {TM1FILTERBYLEVEL({TM1SUBSETALL( [product] )}, 0 )},
            [Merch3].(
                        [Version].[Actual]
                        , [Warehouse].[Group Total]
                        , [Year].[FY15]
                        , [Period].[Week 33]
                        , [Product Status].[All Status]
                        , [Merch3 Measures].[Closing Stock Quantity]
                      ) <> 0
           )
}
I would like to pull from the System Info cube both the Year and the Period/week.

Code: Select all

[System Info].([System Info].[YEAR], [String].[String])
I have been working through the mdx primer and I'm not sure if my syntax is correct or i'm simply just not getting it.

All the best,

James
lotsaram
MVP
Posts: 3703
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Using parameters in MDX (subset editor)

Post by lotsaram »

jdeberardis wrote:I would like to pull from the System Info cube both the Year and the Period/week.

Code: Select all

[System Info].([System Info].[YEAR], [String].[String])
I have been working through the mdx primer and I'm not sure if my syntax is correct or i'm simply just not getting it.
StrToMember is a tricky beast, especially when combining with a larger query. I have another way which I solve the same problem that is simpler. In the system info cube a whole host of time parameters are tracked like current & last year, current & last month, current & last week, etc. a nightly maintenance TI reads the system info cube and maintains single child reporting nodes for each of these relative time periods.

Regardless of whether a user in in the cube viewer or an excel report they can then just query "last week" for example and get the correct result. If you adopt this inyour time dimensions then the MDX becomes trivial as the relative time periods can just be literal strings hardcoded in the MDX as there's a member called "Current FY" and "Last Week".
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
jdeberardis
Posts: 8
Joined: Wed Dec 15, 2010 12:42 am
OLAP Product: TM1
Version: 9.4.x
Excel Version: 2007

Re: Using parameters in MDX (subset editor)

Post by jdeberardis »

Thanks for the reply lotsaram and apologies, I'm not sure what i was thinking yesterday but i only presented part of the problem. Please allow me to have another go :)

I am trying to build a dynamic subset over the product dimension, i've used MDX before to do this and can even do it without the record expression option. I've been racking my brain for sometime on how to retrieve a list of products where the closing stock quantity is not equal to zero. I can hard code both the Year eg FY15, and the period eg Week 33 into the MDX. This list will then be used in excel to retreive product codes and then do some excelly stuff to it. This particular subset will be used by the product team in their weekly reporting. The product dimension is part of a "Merch" cube that they use.

What i would like to do is to have this product list refresh based on the closing stock constraint for a particular year and week and have this done automatically hence the System Info cube which does exactly as you say. It updates based on a TI process on a nightly basis
snapshot of system cube fields
snapshot of system cube fields
systemInfoCube.png (13.7 KiB) Viewed 8402 times
. I would like to reference the AGYEAR and AGWEEK in the MDX of this particular subset to make the list dynamic with little to no intervention from the end-user.

I just noticed that in my code example it looks like i have used "string" as a substitute for the actual dimension.member. Someone set this up before my time and I have not renamed them in a better way. Confusing as all hell :D

A quick thank you for also validating the use of a system cube for dates etc, i didn't know if this was the right approach or if there was a better alternative.

All the best,

James
Post Reply