"GROUP BY" MDX
-
- Posts: 131
- Joined: Tue May 17, 2011 10:04 am
- OLAP Product: TM1
- Version: Planning Analytics 2.0
- Excel Version: 2016
- Location: Freiburg, Germany
"GROUP BY" MDX
Probably there is actually no way of solving that by MDX, but maybe someone can think of a solution? I need a list of products and countries plus a key figure, could be revenue. The challenge is, we want to apply a benchmark to the query, like a list of products and countries where revenue "by product and country" exceeds a certain level.
Any ideas? Thanks in advance, Holger.
Any ideas? Thanks in advance, Holger.
- Steve Rowe
- Site Admin
- Posts: 2422
- Joined: Wed May 14, 2008 4:25 pm
- OLAP Product: TM1
- Version: TM1 v6,v7,v8,v9,v10,v11+PAW
- Excel Version: Nearly all of them
Re: "GROUP BY" MDX
You'll want to use ViewCreateByMDX, rather than the more usual subset logic.
https://www.ibm.com/docs/en/planning-an ... reatebymdx
See https://www.tm1forum.com/viewtopic.php?t=16024 for a hopefully helpful approach on creating one...
https://www.ibm.com/docs/en/planning-an ... reatebymdx
See https://www.tm1forum.com/viewtopic.php?t=16024 for a hopefully helpful approach on creating one...
Technical Director
www.infocat.co.uk
www.infocat.co.uk
-
- Posts: 131
- Joined: Tue May 17, 2011 10:04 am
- OLAP Product: TM1
- Version: Planning Analytics 2.0
- Excel Version: 2016
- Location: Freiburg, Germany
Re: "GROUP BY" MDX
Brilliant, thank you, Steve! This may make me leave my good old 9.5.2 ways behind, looks really powerful... I could not find much syntax help yet, can anyone point me to something?
Regards
Holger
Regards
Holger
- Steve Rowe
- Site Admin
- Posts: 2422
- Joined: Wed May 14, 2008 4:25 pm
- OLAP Product: TM1
- Version: TM1 v6,v7,v8,v9,v10,v11+PAW
- Excel Version: Nearly all of them
Re: "GROUP BY" MDX
MDX views are quite hard, or at least require you to step up your MDX game significantly.
I started by looking at the MDX that PA was generating for a view (there's a lot of noise in this) and then reading up on the MDX documentation, and a lot of trial and error until I got to a method that worked for me.
https://docs.microsoft.com/en-us/analys ... llversions
There's a TM1 example below, I would caveat this to say it is derived from what I see PA report as the MDX used to return a view, I've not pushed harder on this to see if there is a more concise way of writing this! I suspect I could get rid of the cross joins but never really tried.
Edit, missed the last bit off in the original post.
Not sure what release the function arrived in, it's quite possible its not available in 10.2.2. that you list yourself as being on..
A perhaps easier road for you, is to use a ruled measure to flag the intersections you are interested in and then use this to drive the next step in what you are trying to do.
I started by looking at the MDX that PA was generating for a view (there's a lot of noise in this) and then reading up on the MDX documentation, and a lot of trial and error until I got to a method that worked for me.
https://docs.microsoft.com/en-us/analys ... llversions
There's a TM1 example below, I would caveat this to say it is derived from what I see PA report as the MDX used to return a view, I've not pushed harder on this to see if there is a more concise way of writing this! I suspect I could get rid of the cross joins but never really tried.
Code: Select all
sMDX='SELECT NON EMPTY
{[Dim5].[Hier5].[Member]} On 0,
Filter(
NONEMPTY(
CROSSJOIN(TM1SubsetToSet([Dim1].[Hier1], "Front End - Description"),
CROSSJOIN(TM1SubsetToSet([Dim2].[Hier2], "Default"),
CROSSJOIN(TM1SubsetToSet([Dim3].[Hier3], "L0"),
TM1SUBSETALL([Dim4])))),
{{
[Dim5].[Hier5].[Member]
}}),
[Dim5].[Hier5].[Another Member]="ABCDEF")
ON 1 From [Cube]';
Not sure what release the function arrived in, it's quite possible its not available in 10.2.2. that you list yourself as being on..
A perhaps easier road for you, is to use a ruled measure to flag the intersections you are interested in and then use this to drive the next step in what you are trying to do.
Technical Director
www.infocat.co.uk
www.infocat.co.uk
-
- Regular Participant
- Posts: 198
- Joined: Wed May 06, 2020 2:58 pm
- OLAP Product: Planning Analytics
- Version: 2.0.9
- Excel Version: 2016
Re: "GROUP BY" MDX
Following up on Steve's post you can also substitute crossjoin with * to make it a bit easier to read with fewer brackets
Could be replaced by
If you're using an active form you could also just create your report returning everything then use TM1RPTFILTER to filter out and sort
I'd imagine the Mdx view to perform better (not tested) but it's another option
Code: Select all
CROSSJOIN(
TM1SubsetToSet([Dim1].[Hier1], "Front End - Description")
, TM1SubsetToSet([Dim2].[Hier2], "Default")
)
Code: Select all
TM1SubsetToSet([Dim1].[Hier1], "Front End - Description")
*
TM1SubsetToSet([Dim2].[Hier2], "Default")
I'd imagine the Mdx view to perform better (not tested) but it's another option
-
- Posts: 131
- Joined: Tue May 17, 2011 10:04 am
- OLAP Product: TM1
- Version: Planning Analytics 2.0
- Excel Version: 2016
- Location: Freiburg, Germany
Re: "GROUP BY" MDX
Actually I was trying to find a way how to avoid the flags which we currently use, as setting them takes quite some performance and I would rather avoid that. Sounds to me like creating the view through MDX might do the job but I do not seem to have the time to find out how to do it exactly...
Thank you
Holger
Thank you
Holger
-
- Regular Participant
- Posts: 359
- Joined: Sat Jun 08, 2019 9:55 am
- OLAP Product: Planning Analytics
- Version: Planning Analytics 2.0
- Excel Version: Excel 2016
Re: "GROUP BY" MDX
Hi,
I have a question for Steve, why is there no ON 1 (rows) defined in your MDX query, and why is there no From either?
Maren
I have a question for Steve, why is there no ON 1 (rows) defined in your MDX query, and why is there no From either?
Maren
- Steve Rowe
- Site Admin
- Posts: 2422
- Joined: Wed May 14, 2008 4:25 pm
- OLAP Product: TM1
- Version: TM1 v6,v7,v8,v9,v10,v11+PAW
- Excel Version: Nearly all of them
Re: "GROUP BY" MDX
Thanks Maren,
Because in editing the code to make it non company specific I managed to drop off the end of the statement, now updated. Thanks again
Because in editing the code to make it non company specific I managed to drop off the end of the statement, now updated. Thanks again
Technical Director
www.infocat.co.uk
www.infocat.co.uk
-
- MVP
- Posts: 3128
- 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: "GROUP BY" MDX
Couldn’t we have some AI functionality that automatically finishes the statements just the way we wantSteve Rowe wrote: ↑Tue Feb 15, 2022 10:42 am Thanks Maren,
Because in editing the code to make it non company specific I managed to drop off the end of the statement, now updated. Thanks again
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
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