Search code examples
sql-serverreporting-servicesssasmdxssrs-2012

testing mdx query with parameters in SSAS


I'd like to test a MDX query in SSAS. I did the following steps until now.

  1. I opened the SQL Profiler and ran the SSRS report
  2. I found the query I needed (with parameter values) and selected it sql profiler
  3. I pasted the code in ssas
  4. Since my SSRS MDX query used StrToMember and StrToSet functions, I surrounded the parameter values with quotes, e.g. “[Measures].[Return On Average Assets]”.

The query

SELECT 
  {
    [Measures].[Broj Pristapi]
   ,[Measures].[Broj Nalozi]
  } ON 0
 ,
    Except
    (
      StrToSet("[Dim Ucesnici].[Naziv Ucesnik].&;[owiefwjhoef]")
     ,{
        [Dim Ucesnici].[Naziv Ucesnik].&[kihebrgk]
       ,[Dim Ucesnici].[Name].&[blablabla]
      }
    )*
    StrToSet
    ("{ [Dim Web Service Web Method].[Web Service].&;[wsINAPBan],
        [Dim Web Service Web Method].[Web Service].&;[wsNAPSBan] }"
    )*
    StrToSet
    ("{ [Dim Web Service Web Method].[Web Method].[All]
       ,[Dim Web Service Web Method].[Web Method].&;[funNN_loadPP30Ban]
       ,[Dim Web Service Web Method].[Web Method].&;[funNN_loadPP50Ban]}"
    )*
    {
        StrToMember("[Dim Datumi].[Datum ID].&;[20170801]")
      : 
        StrToMember("[Dim Datumi].[Datum ID].&;[20170906]")
    }*
    StrToSet("[Dim Ucesnici].[Opis Tip Ucesnik].&;[Bank]") ON 1
 ,NON EMPTY 
    {
        [Dim Date].[Date].Children*
        [Dim Date].[Month].Children*
        [Dim Date].[MonthName].Children
    } ON 2
 FROM [DW];
  1. I commented out the rest of the lines and just left the mdx query 6.When I ran the query it gave me an error "An MDX expression was expected while a full statement was specified."

I followed the following tutorial for my mdx testing http://prologika.com/how-to-test-ssrs-mdx-queries-in-sql-server-management-studio/

Any idea what the problem might be?


Solution

  • Are you really using this in your member names? .&;[ ....the semi-colon is reserved for the end of mdx statements. Please take out all the semi-colons:

    SELECT 
      {
        [Measures].[Broj Pristapi]
       ,[Measures].[Broj Nalozi]
      } ON 0
     ,
        Except
        (
          StrToSet("{[Dim Ucesnici].[Naziv Ucesnik].&[owiefwjhoef]}")
         ,{
            [Dim Ucesnici].[Naziv Ucesnik].&[kihebrgk]
           ,[Dim Ucesnici].[Name].&[blablabla]
          }
        )*
        StrToSet
        ("{ [Dim Web Service Web Method].[Web Service].&[wsINAPBan],
            [Dim Web Service Web Method].[Web Service].&[wsNAPSBan] }"
        )*
        StrToSet
        ("{ [Dim Web Service Web Method].[Web Method].[All]
           ,[Dim Web Service Web Method].[Web Method].&[funNN_loadPP30Ban]
           ,[Dim Web Service Web Method].[Web Method].&[funNN_loadPP50Ban]}"
        )*
        {
            StrToMember("[Dim Datumi].[Datum ID].&[20170801]")
          : 
            StrToMember("[Dim Datumi].[Datum ID].&[20170906]")
        }*
        StrToSet("[Dim Ucesnici].[Opis Tip Ucesnik].&[Bank]") ON 1
     ,NON EMPTY 
        {
            [Dim Date].[Date].Children*
            [Dim Date].[Month].Children*
            [Dim Date].[MonthName].Children
        } ON 2
     FROM [DW];