如果你采取格雷格·加洛韦的建议,非常适合你。否则,另一个好的MDX
挑战!
以下是您可以做的事情。
首先按照自然顺序排列集合。
接下来,仅针对集合中的当前成员与先前成员不相同或者如果它是第一个成员(在这种情况下当前总是不相同的情况下)的度量[To Pay]
如以前的成员)
with set [Client&Case] as
order
(
[Fact].[ClientID].[All].children * [Fact].[CaseID].[All].children,
[Fact].[ClientID].currentmember.name + "" + [Fact].[CaseID].currentmember.name
)
member measures.[Actual - To Pay] as
sum
(
[Client&Case],
iif
(
not([Client&Case].item([Client&Case].currentordinal-1) is [Client&Case].item([Client&Case].currentordinal-2))
--current not same not as previous
or [Client&Case].currentordinal = 1 --the first member!
,[Measures].[To Pay]
,0
)
)
select
{measures.[Paid], measures.[Actual - To Pay]} on 0,
[Client&Case] on 1
from [Your Cube]
从Adventure Works公司:
with set [Category&Country] as
{
([Product].[Category].&[3], [Customer].[Customer Geography].[Country].&[Australia]),
([Product].[Category].&[3], [Customer].[Customer Geography].[Country].&[Australia]),
([Product].[Category].&[4], [Customer].[Customer Geography].[Country].&[Australia]),
([Product].[Category].&[4], [Customer].[Customer Geography].[Country].&[Australia]),
([Product].[Category].&[4], [Customer].[Customer Geography].[Country].&[Australia])
}
member measures.TotalInternetSales as
sum([Category&Country],[Measures].[Internet Sales Amount])
member measures.[ActualInternetSales] as
sum
(
[Category&Country],
iif
(
not([Category&Country].item([Category&Country].currentordinal-1) is [Category&Country].item([Category&Country].currentordinal-2))
or [Category&Country].currentordinal = 1
,([Category&Country].currentmember, [Measures].[Internet Sales Amount])
,0
)
)
select
{measures.TotalInternetSales, measures.[ActualInternetSales]} on 0
from [Adventure Works]
希望工程。
SSAS Multidimensional or Tabular? – GregGalloway
计算不同的ToPay值似乎非常危险。客户不可能欠两个单独的$ 1000付款吗?你如何区分这两种单独的付款? – GregGalloway
这是但我们将有两个不同的CaseID的。业务案例与租购相关。一个客户可能有两个信用点,我需要知道他已经偿还了多少。我想将它放在一张表中 - 现在我在DSV中创建了查询以获取不同的值,但我很确定可以在MDX中解决它。 –