在MDX中,计算给定商店的销售排名

发布于 2024-09-28 09:36:05 字数 371 浏览 6 评论 0原文

我有一个 OLAP 多维数据集,其中包含我每个商店的销售计数。

使用MDX,如何输出给定商店的排名?

我梦想着像下面这样的东西(不起作用),如果 SomeShop 是第八个最畅销的商店,它将返回 8:

SELECT RANK( [Shop].CHILDREN, [Shop].[SomeShop]) from [Sales]

I have an OLAP cube containing the sales count for each of my shops.

Using MDX, how can I output the rank of a given shop?

I am dreaming about something like below (does not work), it would return 8 if SomeShop is the 8th most-selling shop:

SELECT RANK( [Shop].CHILDREN, [Shop].[SomeShop]) from [Sales]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

静谧 2024-10-05 09:36:05

您应该查看 msdn 上的示例,最后一个示例将在这里工作.
像这样的事情:

WITH MEMBER [Measures].[rank] AS RANK( [Shop].CurrentMember, [Shop].MEMBERS)
SELECT {[Measures].[rank], ...} on 0
ORDER([Shop].MEMBERS, [Measures].[rank], ASC) on 1
FROM [Sales]

You should check out the examples on msdn, the last example will work here.
Something like this:

WITH MEMBER [Measures].[rank] AS RANK( [Shop].CurrentMember, [Shop].MEMBERS)
SELECT {[Measures].[rank], ...} on 0
ORDER([Shop].MEMBERS, [Measures].[rank], ASC) on 1
FROM [Sales]
秋意浓 2024-10-05 09:36:05

这是我找到的解决方案。
任何更好的解决方案将不胜感激。

WITH MEMBER [Measures].[rank] AS RANK(
      [Shop].CurrentMember,
      Order(
         [Shop].Members,
         [Measures].[salescount],
         BDESC
      ),
      [Measures].[salescount]
   )
SELECT Order(
         [Shop].Members,
         [Measures].[salescount],
         BDESC
      ).Item([SomeShop]) ON COLUMNS,
[Measures].[salescount] ON ROWS
FROM [Sales]

Here is the solution I have found.
Any better solution would be greatly appreciated.

WITH MEMBER [Measures].[rank] AS RANK(
      [Shop].CurrentMember,
      Order(
         [Shop].Members,
         [Measures].[salescount],
         BDESC
      ),
      [Measures].[salescount]
   )
SELECT Order(
         [Shop].Members,
         [Measures].[salescount],
         BDESC
      ).Item([SomeShop]) ON COLUMNS,
[Measures].[salescount] ON ROWS
FROM [Sales]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文