SSAS 2014 Trying to write a simple MDX query to slice by column not just by row

im Using Analysis Service for SQL Server 2014. im trying to write a simple query that cuts the amount both by Month on the row level and Vessel Tag on the column level. this get me row just fine, the second i try to cut the amount by column  [Voyage].[Vessel Tag] i get the below error. Whats the correct MDX syntax to slicing it by  [Voyage].[Vessel Tag] for column?

SELECT NON EMPTY { [Measures].[TCE] } ON COLUMNS,
              NON EMPTY { ([Date].[Month].[Month].ALLMEMBERS ) }  ON ROWS
FROM ( SELECT ( { [Date].[Year].&[2017] } ) ON COLUMNS
FROM [cube]) WHERE ( [Date].[Year].&[2017] )

"The query cannot be prepared: The query must have at least one axis.
The first axis of the query should not have multiple hierarchies,
nor should it reference any dimension other than the Measures dimension..
Parameter name: mdx (MDXQueryGenerator)"
Paul MaurielloSoftware Programmer Developer Analyst EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawan KumarDatabase ExpertCommented:
One workaround for this...

Open the EXCEL -> connect to the cube -> get the data in one sheet -> Create the PIVOT as per your need -> then get the MDX query..

Refer -
http://sqlblog.com/blogs/marco_russo/archive/2007/01/18/display-the-mdx-query-of-an-excel-2007-pivottable.aspx
http://olappivottableextend.codeplex.com

you need to download the OLAP Pivot Table Extensions form http://olappivottableextend.codeplex.com ...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Paul MaurielloSoftware Programmer Developer Analyst EngineerAuthor Commented:
Thank you for the quick response. I did exactly that prior to posting but the resulting MDX query produced an error when I run it in the Management Studio. Does this MDX query need to be tweaked for SSMS compatibilty?

SELECT NON EMPTY Hierarchize({DrilldownLevel({[Voyage].[Vessel Tag].[All]},,,INCLUDE_CALC_MEMBERS)})  ON COLUMNS ,
             NON EMPTY Hierarchize({DrilldownLevel({[Date].[Month].[All]},,,INCLUDE_CALC_MEMBERS)})  ON ROWS
 FROM (SELECT ({[Voyage].[Vessel Tag].&[FCCSP, 20K DWT, Eco, Marcinko],
                             [Voyage].[Vessel Tag].&[FCCSP, 20K DWT, Eco, Holway],
                             [Voyage].[Vessel Tag].&[FCCSP, 20K DWT, Eco, Franklin],
                             [Voyage].[Vessel Tag].&[FCCI, 20K DWT, Eco, Marcinko],
                             [Voyage].[Vessel Tag].&[FCCI, 20K DWT, Eco, Leong],
                             [Voyage].[Vessel Tag].&[FCCI, 20K DWT, Eco, Holway],
                             [Voyage].[Vessel Tag].&[FCCI, 20K DWT, Eco]}) ON COLUMNS  
FROM [cube]) WHERE ([Date].[Year].&[2017],[Measures].[TCE])


"The query cannot be prepared: The query must have at least one axis. The first axis of the query should not have multiple hierarchies, nor should it reference any dimension other than the Measures dimension... Parameter name: mdx (MDXQueryGenerator)
0
Pawan KumarDatabase ExpertCommented:
How about this ?

SELECT NON EMPTY Hierarchize({DrilldownLevel({[Voyage].[Vessel Tag].[All]})})  ON COLUMNS , 
             NON EMPTY Hierarchize({DrilldownLevel({[Date].[Month].[All]})})  ON ROWS 
 FROM (SELECT ({[Voyage].[Vessel Tag].&[FCCSP, 20K DWT, Eco, Marcinko], 
                             [Voyage].[Vessel Tag].&[FCCSP, 20K DWT, Eco, Holway],
                             [Voyage].[Vessel Tag].&[FCCSP, 20K DWT, Eco, Franklin], 
                             [Voyage].[Vessel Tag].&[FCCI, 20K DWT, Eco, Marcinko],
                             [Voyage].[Vessel Tag].&[FCCI, 20K DWT, Eco, Leong],
                             [Voyage].[Vessel Tag].&[FCCI, 20K DWT, Eco, Holway], 
                             [Voyage].[Vessel Tag].&[FCCI, 20K DWT, Eco]}) ON COLUMNS  
FROM [cube]) WHERE ([Date].[Year].&[2017],[Measures].[TCE])

Open in new window

0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Paul MaurielloSoftware Programmer Developer Analyst EngineerAuthor Commented:
No unfortunately still same error
0
Pawan KumarDatabase ExpertCommented:
Please try this ..not sure though..dont have cube with me,,

SELECT NON EMPTY Hierarchize({DrilldownLevel({[Voyage].[Vessel Tag].[All]},INCLUDE_CALC_MEMBERS)})  ON COLUMNS , 
             NON EMPTY Hierarchize({DrilldownLevel({[Date].[Month].[All]},INCLUDE_CALC_MEMBERS)})  ON ROWS 
 FROM (SELECT ({[Voyage].[Vessel Tag].&[FCCSP, 20K DWT, Eco, Marcinko], 
                             [Voyage].[Vessel Tag].&[FCCSP, 20K DWT, Eco, Holway],
                             [Voyage].[Vessel Tag].&[FCCSP, 20K DWT, Eco, Franklin], 
                             [Voyage].[Vessel Tag].&[FCCI, 20K DWT, Eco, Marcinko],
                             [Voyage].[Vessel Tag].&[FCCI, 20K DWT, Eco, Leong],
                             [Voyage].[Vessel Tag].&[FCCI, 20K DWT, Eco, Holway], 
                             [Voyage].[Vessel Tag].&[FCCI, 20K DWT, Eco]}) ON COLUMNS  
FROM [cube]) WHERE ([Date].[Year].&[2017],[Measures].[TCE])

Open in new window

0
Paul MaurielloSoftware Programmer Developer Analyst EngineerAuthor Commented:
I got a different error.

Query Preparation failed

Query(2,75) An expression was expected for the function argument and no expression was detected.
Query(1,76) An expression was expected for the function argument and no expression was detected.
0
Pawan KumarDatabase ExpertCommented:
This will not run in SSMS as it is looking for 3rd axis. IN SSMS we can not have 3rd axis.
0
Paul MaurielloSoftware Programmer Developer Analyst EngineerAuthor Commented:
So this MDX query wont even run in stored procedure form to produce a report? Or do you mean it wont execute only in the cube browser in SSMS?
0
Pawan KumarDatabase ExpertCommented:
I think the way we have written the query is a problem we have to modify it. Pls wait checking..
0
Paul MaurielloSoftware Programmer Developer Analyst EngineerAuthor Commented:
I got it. In the SQL Server 2014 Cube Browser it will not let you run an MDX Query that is sliced by column, However if you write the same query in a fresh MDX query window it will run fine, apparently its a limitation of the SQL Server 2014 cube browser itself. Hopefully it will be resolved in future versions. Your first response was actually correct thank you for your help :).
0
Pawan KumarDatabase ExpertCommented:
Oh..... :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSAS

From novice to tech pro — start learning today.