简体   繁体   English

使用尺寸计算的度量

[英]Calculated Measure using dimension

I am trying to build a calculated measure in SSAS that incorporates a dimension parameter. 我正在尝试在SSAS中构建包含维度参数的计算量度。 I have two facts: Members & Orders and one Dimension: Date. 我有两个事实:“成员和订单”和一个维度:“日期”。 Members represents all the unique members on my site. 成员代表我网站上的所有唯一成员。 Orders are related to members by a fact key representing a unique user. 订单通过代表唯一用户的事实键与成员相关。 Orders also contains a key representing the vendor for an order. 订单还包含代表订单供应商的键。 Orders contains a key to the date dimension. 订单包含日期维度的键。

FactMember - MemberFactKey - MemberId FactOrder - FactOrderKey - OrderId - FactMemberKey - DimVendorKey - DimDateKey DimDate - DimDateKey - FYYear FactMember-MemberFactKey-MemberId FactOrder-FactOrderKey-OrderId-FactMemberKey-DimVendorKey-DimDateKey DimDate-DimDateKey-FYYear

The calculated measure I am trying to build is the number of unique vendors a member has ordered from. 我尝试构建的计算得出的度量是成员从其订购的唯一供应商的数量。 The value of the calculation must of course change based on the date dimension. 当然,计算值必须根据日期维度而更改。

I am confused, it would make more sense to make Members and Orders both separate dimensions and then reference them from a FACT table, say Fact.Sales. 我很困惑,将“会员”和“订单”设为两个单独的维度,然后从FACT表中引用它们就更有意义了,例如Fact.Sales。 This would eliminate the need to even build a calculated member if you keyed your Members dimension on some sort of member_key. 如果您在某种member_key上键入Member维度,则甚至不需要构建计算所得的成员。

Wouldn't the DISTINCTCOUNT function be the one to use here? DISTINCTCOUNT函数不是这里要使用的函数吗? Creating a distinct count of Vendors could then be used in this query and elsewhere. 然后可以在此查询和其他地方使用创建不同数量的供应商。

WITH MEMBER [Test]
AS
DISTINCTCOUNT([Vendor].[Vendor].[Vendor])

I will say in advance that this may well be slow (Depending on data volume/distribution), so if this query will be a popular/big part of the design it may be worth considering a restructure. 我会事先说,这可能很慢(取决于数据量/分布),因此,如果此查询将成为设计中的流行/重要组成部分,则可能值得考虑进行重组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM