Page 1 of 1

Filtered by string measure in a 3 dimension cube

Posted: Mon May 14, 2018 11:27 pm
by yyround
Hi all,

I am wondering whether anyone has come across a situation like this:

There is Cube with 3 dimensionS, Dim1, Dim2, DimMeasure. There is a string Measure element under DimMeasure lets called it StrMeasure. StringMeasure is only recorded in the N level elements of Dim1 and Dim2.

Now I want to list all the Dim1 elements (all N level of course) that has a StrMeasure as "AAA".

The following MDX wont do the job, why and how to correct it??

{FILTER({TM1FILTERBYLEVEL( {TM1SUBSETALL( [Dim1] )}, 0)},[Cube].([DimMeasure].[StrMeasure]) = "AAA" )}

If want to take the query further to filter the stringMeasure to return all those has "AAA" as prefix, can we do the query with combination of FILTER AND TM1FILTERBYPATTERN?? Has anyone ever done that?

Many thanks for your time.
YY

Re: Filtered by string measure in a 3 dimension cube

Posted: Tue May 15, 2018 5:31 am
by gtonkin
Your "AAA" string is stored in a cube so filtering by pattern will not work. Have a look around on the forum for where INSTR is used in MDX as you would need to use that to do your wildcard match.

Re: Filtered by string measure in a 3 dimension cube

Posted: Tue May 15, 2018 7:53 am
by Steve Rowe
If you still have access to the Perspectives subset editor then you can record the MDX for what you want by turning the recorder on and then using the filter dialogue.

Re: Filtered by string measure in a 3 dimension cube

Posted: Tue May 15, 2018 8:26 am
by Wim Gielis
Steve Rowe wrote: Tue May 15, 2018 7:53 am If you still have access to the Perspectives subset editor then you can record the MDX for what you want by turning the recorder on and then using the filter dialogue.
Hi Steve,

AFAIK you cannot record an expression when you filter on view extract. The icon is greyed out. Or did you mean something else ?

Re: Filtered by string measure in a 3 dimension cube

Posted: Tue May 15, 2018 12:29 pm
by Steve Rowe
Hi Wim,

I do this a lot to get the base form of the MDX that I want to use in active forms or elsewhere so it is very much possible.

Maybe one of those things that was not available on first release and you've not revisited? That happens to me, small change that I've not picked up on, or maybe just a failing memory...

Cheers,

Re: Filtered by string measure in a 3 dimension cube

Posted: Tue May 15, 2018 12:32 pm
by PavoGa
yyround wrote: Mon May 14, 2018 11:27 pm Hi all,

I am wondering whether anyone has come across a situation like this:

There is Cube with 3 dimensionS, Dim1, Dim2, DimMeasure. There is a string Measure element under DimMeasure lets called it StrMeasure. StringMeasure is only recorded in the N level elements of Dim1 and Dim2.

Now I want to list all the Dim1 elements (all N level of course) that has a StrMeasure as "AAA".

The following MDX wont do the job, why and how to correct it??

{FILTER({TM1FILTERBYLEVEL( {TM1SUBSETALL( [Dim1] )}, 0)},[Cube].([DimMeasure].[StrMeasure]) = "AAA" )}

If want to take the query further to filter the stringMeasure to return all those has "AAA" as prefix, can we do the query with combination of FILTER AND TM1FILTERBYPATTERN?? Has anyone ever done that?

Many thanks for your time.
YY
If you expect this to function properly in a cube view, Dim2 will have to be a context (or title) dimension. If this MDX is to retrieve all Dim1 elements where strMeasure = 'AAA' along the Dim1/Dim2 intersections on its own (say, for building a subset within a TI), then you'll need to use GENERATE on Dim2.

Code: Select all

GENERATE( TM1FILTERBYLEVEL( TM1SUBSETALL( [Dim2] ), 0),
     FILTER( TM1FILTERBYLEVEL( TM1SUBSETALL( [DIM1] ), 0),
          INSTR( [Cube].([Dim2].currentmember, [DimMeasure].[strMeasure], "AAA")) > 0))
BTW, one does not have to use braces (curly brackets) when the function returns a SET. They are needed only when needing to return a SET and the subject is a member of the dimension. Keeps the coding a little cleaner.

Re: Filtered by string measure in a 3 dimension cube

Posted: Wed May 16, 2018 11:20 pm
by yyround
Thank you all for your help.

Much appreciated!

YY

Re: Filtered by string measure in a 3 dimension cube

Posted: Tue May 22, 2018 9:21 am
by Wim Gielis
Steve Rowe wrote: Tue May 15, 2018 12:29 pm Hi Wim,

I do this a lot to get the base form of the MDX that I want to use in active forms or elsewhere so it is very much possible.

Maybe one of those things that was not available on first release and you've not revisited? That happens to me, small change that I've not picked up on, or maybe just a failing memory...

Cheers,
Hello Steve,

I'm on PAL 2.0.4, good old Subset Editor.
I can record an expression with a filter on an attribute, for instance, but not on a view extract. This icon is greyed out when an expression is recorded.

Do you see something different ?

Wim

Re: Filtered by string measure in a 3 dimension cube

Posted: Tue May 22, 2018 9:53 am
by Steve Rowe
Hi Wim,

See below, you can tell the recorder is on because the Save button is greyed out. I seem to get the same behaviour irrespective of how I access the subset editor or the release
MDX filter record.gif
MDX filter record.gif (17.03 KiB) Viewed 6790 times
MDX filter record 2.gif
MDX filter record 2.gif (28.48 KiB) Viewed 6790 times

Re: Filtered by string measure in a 3 dimension cube

Posted: Tue May 22, 2018 12:20 pm
by MGrain
Hi Steve

The Filter by View Extract icon is greyed out in your last screenshot...

I see the same behaviour as Wim, as I press Record Expresssion, that icon and the OK button grey out.

Cheers
Mike

Re: Filtered by string measure in a 3 dimension cube

Posted: Tue May 22, 2018 1:20 pm
by Wim Gielis
I think we speak of different things.

There is Filter in the Tools menu, and Filter by view extract.

The first is possible when an expression is recorded (and can be useful), the second one is not enabled (too bad).

Re: Filtered by string measure in a 3 dimension cube

Posted: Tue May 22, 2018 4:41 pm
by Steve Rowe
Ohhh that "FIlter by View Extract" :oops:

That doesn't work for me either! You can get pretty close with the ordinary filter button though....

Re: Filtered by string measure in a 3 dimension cube

Posted: Tue May 22, 2018 9:38 pm
by Wim Gielis
Indeed Steve