使用 MDX 进行子选择
问候堆栈溢出社区。
我最近开始在 SSAS2008 中构建 OLAP 多维数据集,但遇到了困难。如果有人至少能指出我正确的方向,我将不胜感激。
情况:两个事实表,同一个多维数据集。 FactCalls 保存有关订阅者拨打的电话的信息,FactTopups 保存充值数据。这两个表都有许多共同的维度,其中之一是订阅者维度。
FactCalls FactTopups
订阅者密钥 订阅者密钥
通话时长 DateKey
通话费用 充值价值 ...
我想要实现的是能够根据过去 7 天内为其帐户充值的不同订阅者构建 FactCalls 报告。
我基本上正在寻找与 SQL 等效的 MDX:
select *
from FactCalls
where SubscriberKey in
( select distinct SubscriberKey from FactTopups where ... );
我尝试为包含 SubscriberKey 的两个表创建一个退化维度并执行以下操作:
Exist(
[Calls Degenerate].[Subscriber Key].Children,
[Topups Degenerate].[Subscriber Key].Children
)
没有成功。
亲切的问候,
文斯
Greetings stack overflow community.
I've recently started building an OLAP cube in SSAS2008 and have gotten stuck. I would be grateful if someone could at least point me towards the right direction.
Situation: Two fact tables, same cube. FactCalls holds information about calls made by subscribers, FactTopups holds topup data. Both tables have numerous common dimensions one of them being the Subscriber dimension.
FactCalls FactTopups
SubscriberKey SubscriberKey
CallDuration DateKey
CallCost Topup Value
...
What I am trying to achieve is to be able to build FactCalls reports based on distinct subscribers that have topped up their accounts within the last 7 days.
What I am basically looking for an MDX equivalent to SQL's:
select *
from FactCalls
where SubscriberKey in
( select distinct SubscriberKey from FactTopups where ... );
I've tried creating a degenerate dimension for both tables containing SubscriberKey and doing:
Exist(
[Calls Degenerate].[Subscriber Key].Children,
[Topups Degenerate].[Subscriber Key].Children
)
Without success.
Kind regards,
Vince
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能会发现类似以下内容的效果会更好。过滤器方法将被迫迭代每个订阅者,而 NonEmpty() 函数可以利用存储引擎中的优化。
You would probably find something like the following would perform better. The filter approach will be forced to iterate through each subscriber, while the NonEmpty() function can take advantage of optimizations in the storage engine.
您知道有时最简单、最明显的解决方案却不知何故让您困惑吗?嗯,这显然是其中之一。他们说“MDX 不是 SQL”,我现在知道他们的意思了。我一直从完全 SQL 的角度来研究这个问题,完全忽略了过滤命令的明显使用。
简单得令人尴尬。
You know how sometimes it's the simplest and most obvious solutions that somehow elude you? Well, this is apparently one of them. They say "MDX is not SQL" and I now know what they mean. I've been working at this from an entirely SQL point of view, completely overlooking the obvious use of the filter command.
Embarrassingly simple.