简体   繁体   English

MDX计算的度量计数

[英]MDX Calculated Measure Count

I'm attempting to add a calculated measure to a simple MDX query. 我试图将计算出的量度添加到简单的MDX查询中。

Although I have managed simple calculated measures before I clearly don't understand MDX sufficiently to make this work. 尽管在我显然还不太了解MDX使其无法工作之前,我已经管理了简单的计算方法。

Anyway, what I am trying to do is count the number of distinct orders per each of our truck routes. 无论如何,我想做的是计算每条卡车路线上不同订单的数量。 I have tried counting the Order Dimension Keys but all this does is produce the total number of orders in the system rather than the number of orders per route. 我试过计算订单维键,但所有这些都是在系统中生成订单总数,而不是每条路线的订单数。 Can someone help me out? 有人可以帮我吗? I feel that once I understand this it will make subsequent MDX queries a lot simpler. 我觉得一旦了解了这一点,它将使后续的MDX查询变得简单得多。

With Member Deliveries as

Count([Dim Order].[Order Key].children) --clearly wrong

Select non empty

[Deliveries] on 0,
[Dim Route].[Route Code].Children on 1

From [Defacto DW]

Let's say you have a measure group which connects to this "Orders" dim. 假设您有一个度量组,该度量组连接到此“订单”暗淡。 Lets say you have a measure in this measure group called Measures.Order Count (I am assuming you should be having one). 假设您在此度量标准组中有一个度量,称为Measures.Order Count (我假设您应该有一个)。

If for any order, any route is taken, then for that order-route combination, that order won't be NULL . 如果对于任何订单,采用任何路线,那么对于该order-route组合,该订单不会为NULL

You can then leverage the NonEmpty function to get a count of those non-null intersections. 然后,您可以利用NonEmpty函数获取这些非空交叉点的计数。

With member Deliveries as
NonEmpty
        (
         [Dim Order].[Order Key].[All].children, 
         [Measures].[Order Count]
        ).count

Select 
Deliveries on 0,
[Dim Route].[Route Code].members on 1
From [Defacto DW]

Replace the measure with the actual measure in the cube. 用多维数据集中的实际度量替换度量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM