passing excel variable into MDX

Post Reply
JamiseBondi
Posts: 141
Joined: Wed Nov 14, 2012 10:37 am
OLAP Product: TM1
Version: 2.0
Excel Version: Office 365

passing excel variable into MDX

Post by JamiseBondi »

Hi guys,

I've used the following format in the past to get a variable in excel passed into an MDX statement successfully.
="{FILTER (
{TM1SORT( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [Dimension1] )}, 0)}, ASC)} ,
[CC_Config].([Version].[&CHAR(34)&$F$15&CHAR(34)&],[CC].[HQ],[}ElementAttributes_Dimension1].[Currency])='USD'
) }" The above allows me to choose a version within the workbook (in cell F15) and send it into the MDX to filter for any config in a cube against the relevant version, where the currency is 'USD'. What I'd like to do is also pass the currency from the workbook into the MDX statement to allow me to choose any currency in the workbook and have the MDX filter according to the chosen currency.

So in the above example lets say I'm not hardcoding 'USD' into the MDX statement, I'd like to lookup the currency from cell G15 in the workbook.

I need the single inverted commas on either side of the currency. The workbook reference has the currency without the single inverted comma - CHAR(39).

How would I substitute the 'USD' in the MDX above with an excel cell reference and also have single inverted commas inserted before and after the cell reference - to achieve 'USD' (when the workbook cell reference is simply USD)?

I've tried: ="{FILTER (
{TM1SORT( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [Dimension1] )}, 0)}, ASC)} ,
[CC_Config].([Version].[&CHAR(34)&$F$15&CHAR(34)&],[CC].[HQ],[}ElementAttributes_Dimension1].[Currency])=&CHAR(39)&$G$15&CHAR(39)&
) }" Thanks guys.
Wim Gielis
MVP
Posts: 3120
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: passing excel variable into MDX

Post by Wim Gielis »

I'm not sure it's inverted comma's surrounding USD, I thought it's double quotes on either side.

Try for a more clean suggestion:

="{FILTER( TM1SORT( TM1FILTERBYLEVEL( TM1SUBSETALL( [Dimension1] ), 0), ASC), [CC_Config].([Version].[" & $F$15 & "],[CC].[HQ],[}ElementAttributes_Dimension1].[Currency]) = """ & G15 & """) }"
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
JamiseBondi
Posts: 141
Joined: Wed Nov 14, 2012 10:37 am
OLAP Product: TM1
Version: 2.0
Excel Version: Office 365

Re: passing excel variable into MDX

Post by JamiseBondi »

Thank you Wim,

I was trying to insert a single inverted comma, but excel didn't like " ' "
I used your example of " " " and it worked.
Much appreciated!
Post Reply