Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2355

Inconsistent handling of MDX query axes - member vs set

$
0
0

Hi all,

 

I'm trying to build a XML/A client agaisnt SAP/HANA. I created a XML/A service definition (.xsxmla file) in HANA studio, and I can succesfully access the service and do DISCOVER requests, and execuve MDX statements.

 

The problem I encounter executing MDX is as follows: I can succesfully execute a query like:

 

SELECT {[Measures].[PRICE_EACH]} ON 0
,      {[AT_PRODUCT_001].[HIER_PRODUCT1].&[S10_1678]} ON 1
FROM   [AN_ORDER_001]

 

(Get the Price Each for the product with the key S10_1678 across all other dimensions)

 

But when I try to add a WHERE clause (slicer axis) like so:

 

SELECT {[Measures].[PRICE_EACH]} ON 0
,      {[AT_PRODUCT_001].[HIER_PRODUCT1].&[S10_1678]} ON 1
FROM   [AN_ORDER_001]
WHERE  {[AT_TIME_001].[HIER_TIME1].&[2003-01-06]}

 

I get a SOAP Fault response, with an error message that reads:

 

Error in XMLA Statement: Error occurred while executing a MDX statement. The error message is: [Where clause] expects a parameter that return a [Set: {(...)}]. ["Tuple", "Property", "Member"] return a Set

 

What is this error message trying to tell me? As far as I can see, this MDX statement is valid - all axes have a set of members, that happens to contain just one member. It is clear that this poses no problem on the COLUMNS and ROWS axis, why is it a problem for the slicer axis?


For this particular example, I have found a work-around by not using the curly braces for the slicer axis, i.e. this query:

SELECT {[Measures].[PRICE_EACH]} ON 0
,      {[AT_PRODUCT_001].[HIER_PRODUCT1].&[S10_1678]} ON 1
FROM   [AN_ORDER_001]
WHERE  [AT_TIME_001].[HIER_TIME1].&[2003-01-06]

executes successfully and delivers the expected result.

 

It gets weirder: when I apply the same change to the column axis, i.e. remove the curly braces and write only the one member instead of a SET, like so:

SELECT [Measures].[PRICE_EACH] ON 0
,      {[AT_PRODUCT_001].[HIER_PRODUCT1].&[S10_1678]} ON 1
FROM   [AN_ORDER_001]
WHERE  [AT_TIME_001].[HIER_TIME1].&[2003-01-06]

I get a new SOAP Fault, with the error message:

Error in XMLA Statement: Error occurred while executing a MDX statement. The error message is: [Columns Axis, EMPTY] expects a parameter that return a [Measure: [Measures].[PRICE_EACH]]. ["Property", "Set", "Tuple"] return a Member

(If I put the curly braces back on the COLUMN AXIS, and remove them from the ROW axis, I get again an error with similar message)

What is up with that? Why is the behavior not consistent? And why is the behavior not according to the MDX standard?

 

UPDATE 1: I checked some standards docs. All modern MDX implementations that I have run into support SET expressions in the WHERE clause, and they will automatically treat single members or tuples as well (obviously the conversion from there to a set is trivial). Some sources here (MSAS): https://msdn.microsoft.com/en-us/library/ms146047.aspx

and here (icCube): http://www.iccube.com/support/documentation/mdx/Where%20Clause.php
and here (Oracle Essbase): Oracle Essbase Technical Reference

 

Now, there is a positively ancient document from SQL server 2000 where something is said about the Slicer axis accepting only tuples, but that doc still shows a working examample where multiple tuples (ie, a SET) is used in the WHERE clause:https://technet.microsoft.com/en-us/library/aa216776(v=sql.80).aspx

So, In short, SAP/HANA's implementation seems to be different from all these major MDX implementations. The SAP/HANA developer guide offers almost no information about which standard is being followed here - all I could find is a reference to a <slicer_specification> in the BNF syntax rule for <select_statement> (page 781).

 

Would be really greatful if someone could explain exactly which syntax is being expected, and how I can work around this issue.

 

UPDATE 2: Ok, I found a workaround. I can get it to work if I explicitly create a calculated member myself that Aggregates the individual members. The calculated member can then be used in the WHERE clause, like so:

 

WITH MEMBER [AT_TIME_001].[HIER_TIME1].[test]
AS
AGGREGATE(
 {[AT_TIME_001].[HIER_TIME1].&[2003-01-09],   [AT_TIME_001].[HIER_TIME1].&[2003-01-06]}
) 
SELECT {[Measures].[PRICE_EACH]} ON 0
FROM   [AN_ORDER_001]
WHERE  [AT_TIME_001].[HIER_TIME1].[test]

I would still like to get some feedback on my question though, and it would really be nice if someone could point out a less clumsy and elaborate way to do this. Surely, if I can do this manually, the XML/A engine should be able to do this kind of stuff automatically for us?


Viewing all articles
Browse latest Browse all 2355

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>