MDX 中集合的父母

发布于 2024-12-10 10:50:09 字数 484 浏览 1 评论 0原文

我有一个过滤器,可以在日期维度中选择特定日期,这将作为参数传递到 MDX 查询中。

Filter([Date Dimension].[Calendar Year Hierarchy].[Actual Date].members,
        [Date Dimension].[Actual Date].CurrentMember.Properties( "Name" ) = '2011-09-01 00:00:00.000')

我现在想在上面的层次结构中选择几周和/或几个月。

[日期维度].[日历年层次结构].[月份] [Date Dimension].[Calendar Year Hierarchy].[Calendar Week]

我尝试了几个功能,但运气不佳,例如 .ParentDrillupLevel

我可能使用错误或发错地方了,

感谢帮助

I have a filter that selects a specific date in my date dimension, This will be passed in as a parameter into the MDX query.

Filter([Date Dimension].[Calendar Year Hierarchy].[Actual Date].members,
        [Date Dimension].[Actual Date].CurrentMember.Properties( "Name" ) = '2011-09-01 00:00:00.000')

I would now like to select the weeks and/or months in the hierarchy above that.

[Date Dimension].[Calendar Year Hierarchy].[Month]
[Date Dimension].[Calendar Year Hierarchy].[Calendar Week]

I have tried several functions without much luck such as .Parent and DrillupLevel

I could be using them wrong or in the wrong spot,

thanks for the help

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

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

发布评论

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

评论(4

风透绣罗衣 2024-12-17 10:50:09

您可以使用函数 GENERATE 获取所有祖先:

Generate
 (
   {Filter([Date Dimension].[Calendar Year Hierarchy].[Actual Date].members,
        [Date Dimension].[Actual Date].CurrentMember.Properties( "Name" ) = 
'2011-09-01 00:00:00.000')},
{Ascendants([Date Dimension].[Calendar Year Hierarchy].CurrentMember)}
 )

使用 Adventure Works 查询:

Select 
{[Measures].[Internet Sales Amount]} On Columns,
{Generate(
{Filter([Date].[Calendar].[Date].members,[Date].[Calendar].CurrentMember.Properties("Name") = 'April 1, 2004')}, 
{Ascendants([Date].[Calendar].CurrentMember)})} On Rows
From    [Adventure Works]    

You could use the function GENERATE to get all ascendants:

Generate
 (
   {Filter([Date Dimension].[Calendar Year Hierarchy].[Actual Date].members,
        [Date Dimension].[Actual Date].CurrentMember.Properties( "Name" ) = 
'2011-09-01 00:00:00.000')},
{Ascendants([Date Dimension].[Calendar Year Hierarchy].CurrentMember)}
 )

Query using Adventure Works:

Select 
{[Measures].[Internet Sales Amount]} On Columns,
{Generate(
{Filter([Date].[Calendar].[Date].members,[Date].[Calendar].CurrentMember.Properties("Name") = 'April 1, 2004')}, 
{Ascendants([Date].[Calendar].CurrentMember)})} On Rows
From    [Adventure Works]    
毁梦 2024-12-17 10:50:09

如果您知道要查找的级别,可以使用MDX Ancestor 函数 而不是父函数:

Ancestor([Date Dimension].[Calendar Year Hierarchy].currentmember, 
         [Date Dimension].[Calendar Year Hierarchy].[Month]) 

如果没有,使用父函数就可以了。请注意,使用属性并不是最快的过滤方法(对于非常大的集合)。

为什么不使用 StrToMember MDX 函数

StrToMember( ... here build your member with a string ... ) 

或者您是否可以在字符串生成器的帮助下直接编辑 mdx 创建语句?

If you know the level you're looking for you can use MDX Ancestor function instead of parent:

Ancestor([Date Dimension].[Calendar Year Hierarchy].currentmember, 
         [Date Dimension].[Calendar Year Hierarchy].[Month]) 

If no, it's fine using parent function. Note, using properties is not the quickest method to filter (for very large sets).

Why not using to StrToMember MDX function ?

StrToMember( ... here build your member with a string ... ) 

or if you can edit you mdx directly creating the statement directly with the help of a string builder ?

燃情 2024-12-17 10:50:09

所以我现在的答案是

Filter([日期维度].[日历年层次结构].[实际
日期].成员,[日期维度].[实际
日期].CurrentMember.Properties( "名称" ) = '2011-09-01 00:00:00.000')
.item(0).parent

使用 .item[0] 获取集合中的项目
.parent 来获取该项目的父项(在我的例子中,我实际上调用了它 3 次),

如果有人有任何更好的想法,很乐意将它们放在这里。

so the answer i have at the moment is

Filter([Date Dimension].[Calendar Year Hierarchy].[Actual
Date].members, [Date Dimension].[Actual
Date].CurrentMember.Properties( "Name" ) = '2011-09-01 00:00:00.000')
.item(0).parent

using the .item[0] to get the item in the set
and the .parent to get that items parent (in my case i am actually calling it 3 times)

if anyone has any better ideas would love to here them.

岛歌少女 2024-12-17 10:50:09

您可以使用 STRTOSET 并为每个输入参数替换 ]].Parent,这样您将拥有一组父项。

You can use STRTOSET and for each input parameter replace ] with ].Parent, this way you will have set of parents.

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