在 mdx 查询中显示成员的属性
我有一个 Mondrian/MDX 查询,我在其中获取日期范围内的数据,但我想返回时间作为结果中其属性的值。我当前的查询如下:
With
set [*TIME_RANGE] as '{[Time].[2011].[3].[9].[1].[1].Lag(30):[Time].[2011].[3].[9].[1].[1]}'
set [*PXMD] as '[meta_pixel_id1.Pixel].[label].Members'
set [*BASE_MEMBERS] as 'NonEmptyCrossJoin([*TIME_RANGE],[*PXMD])'
Select
{[Measures].[total_users],[Measures].[total_action_pixels]} on columns,
[*BASE_MEMBERS] on rows
From [ActionPixels]
Where [Pixel ID].[500]
返回的结果如下:
Axis #0:
{[Pixel ID].[500]}
Axis #1:
{[Measures].[total_users]}
{[Measures].[total_action_pixels]}
Axis #2:
{[Time].[2011].[3].[8].[4].[24], [meta_pixel_id1.Pixel].[500].[Action].[Type].[Handraiser]}
{[Time].[2011].[3].[8].[4].[24], [meta_pixel_id1.Pixel].[500].[Action].[Type].[Lead]}
{[Time].[2011].[3].[8].[4].[24], [meta_pixel_id1.Pixel].[500].[Action].[Type].[Shopper]}
Row #0: 3
Row #0: 3
Row #1: 4
Row #1: 4
Row #2: 2
Row #2: 2
这是我所期望的。问题是,我编写这个查询是为了在 Pentaho xaction 中使用,所以之后我有一些 Javascript 代码将其转换为 JSON 格式,当我提取 [Time]
的值时列中,我只返回日期数字(在本例中为 24
)。我想要显示的是 [Time].[Day]
维度的属性,我们称之为 Date String
,其中包含格式为年月日的日期。但我找到的关于如何执行此操作的示例都不适用于我按范围对 [Time]
的选择。
最直接的解决方案似乎是显示 Date String
属性,但我愿意考虑其他想法,让我既可以获得所需的数据,又可以筛选所需的时间范围。
I have a Mondrian/MDX query where I grab data within a date range, but I'd like to return time as the value of its property in the result. My current query is like:
With
set [*TIME_RANGE] as '{[Time].[2011].[3].[9].[1].[1].Lag(30):[Time].[2011].[3].[9].[1].[1]}'
set [*PXMD] as '[meta_pixel_id1.Pixel].[label].Members'
set [*BASE_MEMBERS] as 'NonEmptyCrossJoin([*TIME_RANGE],[*PXMD])'
Select
{[Measures].[total_users],[Measures].[total_action_pixels]} on columns,
[*BASE_MEMBERS] on rows
From [ActionPixels]
Where [Pixel ID].[500]
Which returns a result like:
Axis #0:
{[Pixel ID].[500]}
Axis #1:
{[Measures].[total_users]}
{[Measures].[total_action_pixels]}
Axis #2:
{[Time].[2011].[3].[8].[4].[24], [meta_pixel_id1.Pixel].[500].[Action].[Type].[Handraiser]}
{[Time].[2011].[3].[8].[4].[24], [meta_pixel_id1.Pixel].[500].[Action].[Type].[Lead]}
{[Time].[2011].[3].[8].[4].[24], [meta_pixel_id1.Pixel].[500].[Action].[Type].[Shopper]}
Row #0: 3
Row #0: 3
Row #1: 4
Row #1: 4
Row #2: 2
Row #2: 2
Which is what I expect. Problem is, I'm writing this query for use in a Pentaho xaction, so I have some Javascript code afterwards that converts this into a JSON format and when I got to extract the value of the [Time]
column, I get back only the day number (in this case, 24
). What I want to display instead is the property of the [Time].[Day]
dimension we call Date String
that contains the date formatted as year-month-day. But none of the examples I can find of how to do this will work with my selection on [Time]
by range.
The most immediate solution seems to be to display the Date String
property, but I'd be willing to entertain other ideas that will let me get both the data I want and filter on the time range I want.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够根据 在线找到的代码。我之前曾尝试过类似的方法,但它不起作用,因为最终是多维数据集中的属性出现问题,导致它始终返回 null,而不是创建时间维度的表中的值。
I was able to solve the problem based on the code found online. I had tried something like that before, but it wasn't working because of what was ultimately a problem with the property in the cube that caused it to always return null rather than the value in the table the time dimension was created from.