总结 SSAS 中的多个 MDX 查询
我需要对多个查询的结果求和。
我面临的挑战是每个查询都定义了成员(以计算日期范围),
我需要能够跨多个 mdx 查询对这些成员进行组合/求和,
WITH Member [M1] AS Sum(DateRange, Measure)
SELECT [M1]
FROM [Cube]
WHERE {[x].&[y]}
WITH Member [M1] AS Sum(Different DateRange, Measure)
SELECT [M1]
FROM [Cube]
WHERE {[z].&[q]}
每个查询根据不同的条件选择相同的成员。
我能想到的唯一方法是 UNION 和 SUM([M1]) 但不知道这在 MDX
UPDATE 中是如何可能的 - 回答 icCube 问题,这就是为什么我需要为每个都有一个单独的 WHERE 子句查询:
我需要为每个查询单独的 WHERE 部分,因为我需要聚合不同切片的结果。我的切片由 n 个维度定义。我根据用户配置输入动态发出每个切片的 mdx 查询(并动态构造我的 WHERE 子句以按用户首选项进行过滤)。用户可以配置重叠的切片(这些是我需要总结的)。然后我需要将这些切片行计数合并到一个报告中。我正在做的方法是将带有 MDX 查询的字符串传递给报告。但由于我想不出一种方法将多个查询放入一个可执行字符串中,(我也不知道会有多少个查询)这种方法不再可能(除非有某种方法将它们联合/求和
。我现在能想到实现这一目标的唯一方法是使用额外的批处理步骤,该步骤将迭代所有查询,将它们处理(使用 Adomd.net)到临时表中,然后我可以使用 SQL 将它们聚合到一个报告中sum(..)。这种方法的最大缺点是需要维护额外的系统,并且报告中的数据更有可能过时。
i need to SUM the results of multiple queries.
the challenge that i have is that each query has defined members (to calculate a date range)
i need to be able to combine/sum those members across multiple mdx queries
WITH Member [M1] AS Sum(DateRange, Measure)
SELECT [M1]
FROM [Cube]
WHERE {[x].&[y]}
WITH Member [M1] AS Sum(Different DateRange, Measure)
SELECT [M1]
FROM [Cube]
WHERE {[z].&[q]}
each query selects the same members based on different criteria.
the only way i can think of doing this is a UNION and than SUM([M1]) but no idea how that is possible in MDX
UPDATE - in reply to icCube question, here is why i need to have a separate WHERE clause for each query:
i need separate WHERE sections for each query because i need to aggregate the results of different slices. and my slices are defined by n number of dimensions. i emit the mdx query for each slice dynamically based on user configuration input (and construct my WHERE clause dynamically to filter by user preferences). Users are allowed to configure overlapping slices (these are the ones i need to sum up together). then I need to combine these slice row counts into a report. The way i am doing is by passing a string with MDX query to a report. but since i can't think of a way to get multiple queries into one executable string, (nor do i know how many queries there will be) this approach is no longer possible (unless there is some way to union / sum them.
The only way i could think of accomplishing this for now, is with additional batching step that will iterate through all queries, process them (using Adomd.net) into a staging table, and then i can aggregate them into a report using SQL sum(..). Biggest disadvantage to this approach being additional system to be maintained and more possibilities that the data in the report will be stale.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不确定这是否是您正在寻找的内容
,或者
我不知道有什么方法可以在 MDX 中添加两个选择的结果...
Not sure if this is what you're looking
or
I don't know any way adding the result of two selects in MDX...
我相信你需要的是
Aggregate()
而不是Sum。I believe you need
Aggregate()
not Sum.您可以通过以下方式使用 SubCube 在 MDX 中实现 UNION 行为:
You could implement the UNION behavior in MDX using SubCubes on this way: