Page 1 of 1

quote issue on a MDX TurboIntegrator function

Posted: Fri Jan 20, 2023 9:48 am
by sblot
Hello,

I would like to create a MDX subset in my TurboIntegrator process, with an attribute variable. But I have a quote issue.
Let's illustrate with an example:

***************************************************************

This code works well:

vMDX = '{FILTER(TM1SubsetAll([vDimension1].[vDimension1]), ([vDimension1].[vDimension1].CURRENTMEMBER.PROPERTIES("vAttribute1") = "vValue"))}';
vSubsetName1='zSubSet_' | vDimension1;
SubsetCreatebyMDX(vSubsetName1,vMDX);
SubsetMDXSet(vDimension1,vSubsetName1,'');

DataSourceType='SUBSET';
DatasourceNameForServer=vDimension1;
DatasourceDimensionSubset=vSubsetName1;

***************************************************************

Now, I would like to use a variable on my "vValue", so i wrote:
vMDX = '{FILTER(TM1SubsetAll([vDimension1].[vDimension1]), ([vDimension1].[vDimension1].CURRENTMEMBER.PROPERTIES("vAttribute1") = ' | vValue | ' )}';

But the result is wrong, because my code does not have the vValue between quotes. It generates: {FILTER(TM1SubsetAll([vDimension1].[vDimension1]), ([vDimension1].[vDimension1].CURRENTMEMBER.PROPERTIES("vAttribute1") = vValue))}

I guess there is a simple solution, but I don't have it. Do you have any clue?
Have a nice day.
sblot

Re: quote issue on a MDX TurboIntegrator function

Posted: Fri Jan 20, 2023 9:58 am
by burnstripe
Change the syntax to this

vMDX = '{FILTER(TM1SubsetAll([vDimension1].[vDimension1]), ([vDimension1].[vDimension1].CURRENTMEMBER.PROPERTIES("vAttribute1") = "' | vValue | '" )}';

Notice the double quote before the single quote before vvalue and a double quote after the following single quote

Re: quote issue on a MDX TurboIntegrator function

Posted: Fri Jan 20, 2023 11:28 am
by gtonkin
Another approach to consider is using Expand() - This makes these MDX queries easier to read by limiting all the quotes needed:

Code: Select all

vMDX = Expand('{FILTER(TM1SubsetAll([vDimension1].[vDimension1]), ([vDimension1].[vDimension1].CURRENTMEMBER.PROPERTIES("vAttribute1") = "%vValue%")}');

Re: quote issue on a MDX TurboIntegrator function

Posted: Fri Jan 20, 2023 11:37 am
by lotsaram
+1 I would also always use Expand for such cases. It's just easier.

Re: quote issue on a MDX TurboIntegrator function

Posted: Fri Jan 20, 2023 2:57 pm
by sblot
Thank you burnstripe, it is working well now.

I did not know this expand function. I will try it so, thanks for the tip.

Re: quote issue on a MDX TurboIntegrator function

Posted: Fri Jan 20, 2023 5:10 pm
by MarenC
I did not know this expand function.
My advice, learn it!

Re: quote issue on a MDX TurboIntegrator function

Posted: Wed Jan 25, 2023 9:19 pm
by PavoGa
Always use EXPAND() as well. Makes parsing more complex MDX easier to read vs. concatenations to me.

Re: quote issue on a MDX TurboIntegrator function

Posted: Thu Jan 26, 2023 10:19 pm
by Wim Gielis
Just pay attention to 2 things:
- Expand with numbers gives you a certain format with 3 decimal digits
- Expand of an Expand whereby the inner Expand resolves to something that contains a % character will cause you headaches.