3

I am always getting a single value in MDX query using python. I am connecting to icCube which has xmla support.

provider = xmla.XMLAProvider()
con = provider.connect(location='conn_str',username='q1',password='q2')
cmd="""WITH MEMBER Measures.[Avg Profit Margin] AS Sum(SOMETHING,    Measures.[Profit Margin]) select NON EMPTY {[Measures].[Profit Margin]} ON columns, {[Client Country]} ON rows FROM [XYZ]"""

res=con.Execute(cmd,Catalog="cube_closed_contracts")
print res.getSlice()

why does it always return a single value?

[[(Cell){
     _CellOrdinal = "0"
     Value = 0.0358054
     FmtValue = "3.58%"
   }]]
Marc Polizzi
  • 9,275
  • 3
  • 36
  • 61
Animesh Saxena
  • 449
  • 4
  • 11

1 Answers1

1

Are you sure the MDX query is expected to return more than one cell ?

WITH MEMBER Measures.[Avg Profit Margin] AS ... 
select 
      NON EMPTY {[Measures].[Profit Margin]} ON columns, 
      {[Client Country]} ON rows 
FROM [XYZ]

" [Client Country] on rows " means the default member of [Client Country] so I believe this will return a single cell result. I would try the request in the icCube MDX editor.

Hope that helps.

Marc Polizzi
  • 9,275
  • 3
  • 36
  • 61
  • 2
    Thanks for the suggestion. I was able to modify the query and test in MDX editor. I still don't know why the python xmla package doesn't return column names from res object. Inside iccube i can type in the mdx query and get a nicely formatted table with column names etc. In the python interface it's just values. – Animesh Saxena Apr 03 '15 at 08:22