如何在 MDX 计算成员中传递多值参数?

发布于 2024-11-02 05:22:32 字数 482 浏览 5 评论 0原文

我实际上正在使用 SQL Server Reporting Services 开发 SSAS 多维数据集。 为了过滤字段,我需要使用专门使用参数的计算成员。

这是我的计算成员:

WITH MEMBER [Measures].[Comparable Stock Room] AS Iif (
    [Stock room].[Stock room code].currentMember IS (Iif (STRTOMEMBER(@StockRoomCode).Count = 1, STRTOMEMBER(@StockRoomCode), xxx)),
    0,
    [Measures].[Retail sales amount invoiced including tax] 
)

如果 @StockRoomCode 只有一个值,则效果很好。但我不知道当参数有多个值时如何使其工作。如何替换“xxx”? 您能帮助我或告诉我如何更好地做到这一点吗,谢谢!

I'm actually working on a SSAS Cube using SQL Server Reporting Services.
In order to filter a field, I need to use a calculated member which specifically use a parameter.

Here is my calculated member:

WITH MEMBER [Measures].[Comparable Stock Room] AS Iif (
    [Stock room].[Stock room code].currentMember IS (Iif (STRTOMEMBER(@StockRoomCode).Count = 1, STRTOMEMBER(@StockRoomCode), xxx)),
    0,
    [Measures].[Retail sales amount invoiced including tax] 
)

This works well if @StockRoomCode only have one value. But I don't know how to make it works when the parameter has multiple values. How to replace the 'xxx' ?
Can you help me or tell me how to do it a better way, thanks !

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

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

发布评论

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

评论(1

晨敛清荷 2024-11-09 05:22:32

您可以创建一个计算成员,聚合您想要报告的成员,并在计算成员的项中定义度量,例如:(

with member [Stock Room].[Stock room code].[foo] as
aggregate (strtoset (@StockRoomCode)),

member [Measures].[Comparable Stock Room] as
([Stock Room].[Stock room code].[foo],
 [Measures].[Retail sales amount including tax])

注意:未经测试,只是我的想法)。或者,

with set [foo] as strtoset (@StockRoomCode),

member [Measures].[Comparable Stock Room] as
       sum ([foo], [Measures].[Retail sales amount including tax])

select [Measures].[Comparable Stock Room] on columns,
       (Slicing dimension such as time) on rows
  from [cube]
 where [other slice]

请注意,无论使用哪种方法,都应先正确设置表达式并进行测试。

You could create a calculated member aggregating the members you want to report on and define the measure in tems of the calculated member, something like:

with member [Stock Room].[Stock room code].[foo] as
aggregate (strtoset (@StockRoomCode)),

member [Measures].[Comparable Stock Room] as
([Stock Room].[Stock room code].[foo],
 [Measures].[Retail sales amount including tax])

(Note: not tested, just off the top of my head). Or,

with set [foo] as strtoset (@StockRoomCode),

member [Measures].[Comparable Stock Room] as
       sum ([foo], [Measures].[Retail sales amount including tax])

select [Measures].[Comparable Stock Room] on columns,
       (Slicing dimension such as time) on rows
  from [cube]
 where [other slice]

Note, with either, get your set expression right and test that first.

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