我的计算度量[Measures].[Person Count]
定义为DISTINCTCOUNT(Visits[Person ID])
。我们的财政年度从7月到6月。我想提一份报告,按财政月份显示该月的不同人数以及总计。但是,运行总计还需要考虑不同的值。以下是几乎的工作原理:
WITH MEMBER [Measures].[Cumulative Person Count] AS
Sum(PeriodsToDate([Date].[Fiscal Calendar].[Fiscal Year],
[Date].[Fiscal Calendar].CurrentMember),
[Measures].[Person Count])
SELECT [Date].[Fiscal Calendar].[Month].MEMBERS ON COLUMNS,
{ [Measures].[Person Count],
[Measures].[Cumulative Person Count] } ON ROWS
FROM [Model]
WHERE [Date].[FiscalYear].&[2018]
这给出了如下内容:
+-------------------------+-------+--------+-----------+...
| | July | August | September |...
+-------------------------+-------+--------+-----------+...
| Person Count | 34268 | 37270 | 35971 |...
| Cumulative Person Count | 34268 | 71538 | 107509 |...
+-------------------------+-------+--------+-----------+...
“人数”数字是正确的。然而,“累积人数”仅仅是总结每个月的总数,而不知道重复数据。假设每个月只有10%的人员记录是新的。我希望看到的结果如下:
+-------------------------+-------+--------+-----------+...
| | July | August | September |...
+-------------------------+-------+--------+-----------+...
| Person Count | 34268 | 37270 | 35971 |...
| Cumulative Person Count | 34268 | 37995 | 41592 |...
+-------------------------+-------+--------+-----------+...
重用[Measures].[Person Count]
度量但将其应用于了解上下文的不同范围的最佳方法是什么?
答案 0 :(得分:0)
您可能只是使用了错误的聚合类型 - 请改为AGGREGATE
:
WITH MEMBER [Measures].[Cumulative Person Count] AS
AGGREGATE(
PeriodsToDate(
[Date].[Fiscal Calendar].[Fiscal Year],
[Date].[Fiscal Calendar].CurrentMember),
[Measures].[Person Count]
)
PeriodsToDate
的替代方案可能是使用NULL:..
:
AGGREGATE(
{ NULL : [Date].[Fiscal Calendar].CurrentMember }
,[Measures].[Person Count]
)