Page 1 of 1

numeric variable in mdx query

Posted: Thu Oct 15, 2015 2:02 pm
by bunkersoldier
Hi all
This is hopefully a simple question, 'Can you use a tm1 defined numeric variable within an MDX query?'
I will show my example below;
nMin = CellGetN( cControlCube, 'HLC001', pAccount, 'HLE001' );

sCompanyMDX =
' { TOPCOUNT( { [HL Company] . [HLC001] . Children }, nMin, [ ' | cSourceCubeName | ' ] . ( [Period].[ ' | pPeriod | ' ], [Year].[ ' | pYear | ' ], [HL Account].[ ' | pAccount | ' ], [HL Measure] . [ ' | cAbs | ' ] ) ) };

The value in the cControlCube is 3
All the other variables are string in nature and if I replace nMin in the MDX query with the number 3 it all works perfectly.
I am hoping that it is just a syntax issue. I have also tried | nMin | and ' | nMin | ' neither of which worked

Thanks in advance for any help

Re: numeric variable in mdx query

Posted: Thu Oct 15, 2015 2:13 pm
by declanr
Your issue is that the TI code views sCompanyMDX as a string variable; it doesn't really concern itself with what it will be used for or where it has come from BUT all component of it must be entered into it as string (even if they are a number)... later when it is passed in to MDX the MDX compiler will then use the characters that individually make up your string to deduce whether each one is delimited as a string or numeric component of the overall.

e.g. NumberToString ( nMin ) will be needed; you do have a few other syntax issues with your code however (e.g. where you are placing pipes etc.)

I recommend that you keep tweaking and ASCII output the variable that you are creating; keep manually copying and pasting that output to a subset editor window until it correctly resolves and then you know it is successful.

Re: numeric variable in mdx query

Posted: Thu Oct 15, 2015 3:16 pm
by bunkersoldier
Thanks declanr, all working