MDX - TopCount 加上“其他” 或“其余的”

发布于 2024-07-18 03:51:38 字数 729 浏览 4 评论 0原文

我创建了一个 MDX 查询,用于计算前 10 个邮政编码(根据我的患者住院测量),如下所示:

WITH
MEMBER [Discharge Date].[Y-M-D].[ Aggregation] AS 'AGGREGATE( EXISTING { [Current Month] } )', SOLVE_ORDER = 0

SELECT
NON EMPTY { [Measures].[Patient Stays] }
ON COLUMNS,

TOPCOUNT({ ORDER( HIERARCHIZE( { [Patient].[ByZipcode].[All].CHILDREN } ), ( [Measures].[Patient Stays] ), BDESC ) }, 10)
ON ROWS

FROM [Patient Stay]

WHERE ( [Discharge Date].[Y-M-D].[ Aggregation], [Facility].[ByAffiliation].CURRENTMEMBER, [Facility].[ByRegion].CURRENTMEMBER )

此查询用于填充 PerformancePoint 100% 堆叠条形图。 客户要求,由于这是一个基于 !00% 的图表,我们将其余的邮政编码集中到“其他”字段中,这样应该有 11 个值:前 10 个值各一个,第十一个值代表前 10 个值。是其余邮政编码的总和。

我是 MDX 的新手,但这听起来并不是不可能的。 有人有什么想法或建议吗?

I have created an MDX query which calculates the TOP 10 ZipCodes (according to my Patient Stay measure) as such:

WITH
MEMBER [Discharge Date].[Y-M-D].[ Aggregation] AS 'AGGREGATE( EXISTING { [Current Month] } )', SOLVE_ORDER = 0

SELECT
NON EMPTY { [Measures].[Patient Stays] }
ON COLUMNS,

TOPCOUNT({ ORDER( HIERARCHIZE( { [Patient].[ByZipcode].[All].CHILDREN } ), ( [Measures].[Patient Stays] ), BDESC ) }, 10)
ON ROWS

FROM [Patient Stay]

WHERE ( [Discharge Date].[Y-M-D].[ Aggregation], [Facility].[ByAffiliation].CURRENTMEMBER, [Facility].[ByRegion].CURRENTMEMBER )

This query is used to populate a PerformancePoint 100% Stacked Bar chart. The client has asked that since this is a !00% based chart, we lump the rest of the zip codes into an "Other" field, such that there should be 11 values: one for each of the top 10, and an eleventh which is a sum of the remaining Zip Codes.

I am an extreme novice to MDX, but this doesn't souund like it should be impossible. Does anyone have any ideas or suggestions?

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

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

发布评论

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

评论(1

本宫微胖 2024-07-25 03:51:38

我会尽力使用未经测试的代码,所以这里是:

WITH
MEMBER [Discharge Date].[Y-M-D].[ Aggregation] AS 'AGGREGATE( EXISTING { [Current Month] } )', SOLVE_ORDER = 0

SET [Top10ZipCodes] AS 
    (TOPCOUNT({ ORDER( HIERARCHIZE( { [Patient].[ByZipcode].[All].CHILDREN } ), ( [Measures].[Patient Stays] ), BDESC ) }, 10))

MEMBER [Patient].[ByZipCode].[OtherZipCodes] AS 
    (AGGREGATE({EXCEPT([Patient].[ByZipCode].Members, [Patient].[ByZipCode].[Top10ZipCodes])}))

SELECT
NON EMPTY { [Measures].[Patient Stays] }
ON COLUMNS,

{[Top10ZipCodes], [Patient].[ByZipCode].[OtherZipCodes]}
ON ROWS

FROM [Patient Stay]

WHERE ( [Discharge Date].[Y-M-D].[ Aggregation], [Facility].[ByAffiliation].CURRENTMEMBER, [Facility].[ByRegion].CURRENTMEMBER )

它的作用是创建一组前 10 个邮政编码,然后聚合(与总和不同!!!)所有邮政编码,除了您的前 10 个邮政编码之外10.

此外,如果这是一个通用集(前 10 个邮政编码),您可能需要在多维数据集上创建一个集,这样您就可以重复使用它,而不必更改您拥有的每个 MDX 查询。

干杯,
埃里克

I'll do my best with untested code, so here goes:

WITH
MEMBER [Discharge Date].[Y-M-D].[ Aggregation] AS 'AGGREGATE( EXISTING { [Current Month] } )', SOLVE_ORDER = 0

SET [Top10ZipCodes] AS 
    (TOPCOUNT({ ORDER( HIERARCHIZE( { [Patient].[ByZipcode].[All].CHILDREN } ), ( [Measures].[Patient Stays] ), BDESC ) }, 10))

MEMBER [Patient].[ByZipCode].[OtherZipCodes] AS 
    (AGGREGATE({EXCEPT([Patient].[ByZipCode].Members, [Patient].[ByZipCode].[Top10ZipCodes])}))

SELECT
NON EMPTY { [Measures].[Patient Stays] }
ON COLUMNS,

{[Top10ZipCodes], [Patient].[ByZipCode].[OtherZipCodes]}
ON ROWS

FROM [Patient Stay]

WHERE ( [Discharge Date].[Y-M-D].[ Aggregation], [Facility].[ByAffiliation].CURRENTMEMBER, [Facility].[ByRegion].CURRENTMEMBER )

What this does is creates a set of your top 10 ZIP codes, and then aggregates (different than sum!!!) all the ZIP codes, with the exception of your top 10.

Also, if this is a common set (top 10 ZIP codes), you may want to make a set on the cube, where you can reuse it ad nauseum, without having to change every MDX query you have.

Cheers,
Eric

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文