6

I am new to working with Business Intelligence/Analysis Services and MDX queries. I am developing a web app that pulls/embeds reports from a report server (SSRS reports build upon this cube data), however the result is slow and the resulting look is lacking IMO. I am also generating chart widgets using the same method (looks even worse).

To find a new solution one task at a time, I have explored the possibility of generating the widgets (bar, pie, line chats etc...) with some really nice SVG javascript libraries. However, these libraries are wanting to be supplied data in JSON or XML (some other formats supported like CSV as well...).

I'd like to ditch my current use of the reporting widgets, and attempt to render my own charts based on this cube data. However, I am at a loss for gathering the data in the appropriate format. I'd prefer JSON to save file size, but XML will suffice. Any suggestions?

4

1 回答 1

5

事实上,在底层,从 SSAS 返回的所有结果都在 XMLA 中,即 XML。这个 XMl 包含很多您可能不需要的元数据信息。

要查看某些 MDX 语句的结果,您可以在 Management Studio 中运行 XMLA 查询,如下所示: 打开 XMLA 窗口并输入包含在 XMLStatement元素中的 MDX,如下所示:

<Statement>
  select [Date].[Calendar].[Calendar Year].Members
         on columns,
         [Sales Territory].[Sales Territory Country].Members
         on rows
    from [Adventure Works]
</Statement>

这将以所谓的多维格式以 XML 形式返回结果。还有一种表格格式,它更像是一个关系结果集。您可以使用完整的语法来获得它:

<Execute xmlns="urn:schemas-microsoft-com:xml-analysis">
  <Command>
    <Statement>
      select [Date].[Calendar].[Calendar Year].Members
             on columns,
             [Sales Territory].[Sales Territory Country].Members
             on rows
        from [Adventure Works]
    </Statement>
  </Command>
  <Properties>
    <PropertyList>
      <Catalog>Adventure Works DW 2008</Catalog>
      <Format>Tabular</Format>
    </PropertyList>
  </Properties>
</Execute>

如果将 更改<Format>Tabular</Format><Format>Multidimensional</Format>,您应该得到与我的第一个代码示例相同的结果。事实上,Management Studio 只是用一些 XML 将我上面显示的第一个代码包围起来,因此它看起来与我的第二个代码示例相似,以便为您节省一些输入。

一些备注:

  • 在您的 MDX 代码中,您必须转义一些字符,例如& 并使<请求有效 XML。
  • 完整代码中的<Catalog>Adventure Works DW 2008</Catalog>部分是您访问的目录(即数据库)的名称。
  • XMLA 语法的文档可以在这里找到:http: //msdn.microsoft.com/en-us/library/ms186691.aspx
于 2013-09-06T10:57:00.190 回答