我每周都会提供销售数据,每季度提供一次查询数据。 在SSAS数据立方体中,我预先计算了每个时间段的销售数据的平均值,我需要做的是从LookupTable获取相关记录以进行下一次计算,其中: LookupTable.Min<销售额平均值< LookupTable.Max
示例:
销售= 297 + 33 + 311 = 641
SalesAverage = 213.66
LookupRecordShrinkageIndicator = Min< SalesAverage< Max = 0< 213.66< 9000 = 0.007
CREATE TABLE dbo.SalesData
(
Id int,
Sales decimal(18, 2) )
CREATE TABLE dbo.LookupTable
(
Id int,
Min int,
Max int,
Shrinkage decimal(10, 5),
Wages decimal(10, 5),
Waste decimal(10, 5)
)
INSERT [dbo].[SalesData] ([Id], [Sales]) VALUES (1, 297)
INSERT [dbo].[SalesData] ([Id], [Sales]) VALUES (2, 33)
INSERT [dbo].[SalesData] ([Id], [Sales]) VALUES (3, 311)
INSERT [dbo].[LookupTable] ([Id], [Min], [Max], [Shrinkage], [Wages], [Waste]) VALUES (1, 0, 9000, 0.00700, 0.12700, 0.00300)
INSERT [dbo].[LookupTable] ([Id], [Min], [Max], [Shrinkage], [Wages], [Waste]) VALUES (2, 9000, 9250, 0.00700, 0.12700, 0.00300)
INSERT [dbo].[LookupTable] ([Id], [Min], [Max], [Shrinkage], [Wages], [Waste]) VALUES (3, 9250, 9500, 0.00700, 0.12300, 0.00300)
我需要根据销售平均值创建计算成员,其中包含查找表中的指标以供下次计算。
答案 0 :(得分:1)
要解决这个问题,我必须使用LookupTable作为维度和度量,让我们看看我是如何做到的。
根据LookupTable创建维度:
添加查找度量执行多维数据集并将查找维度添加到多维数据集。
在Lookup维度和查找度量值组之间创建事实关系
这就是全部:
让我们看看mdx示例:
SELECT
{
FILTER([Lookup Table].[Id].AllMembers , [Measures].[Min] <= 213 AND [Measures].[Max] > 213 )
}
ON COLUMNS,
{
[Measures].[Shrinkage - Lookup Table], [Measures].[Wages - Lookup Table], [Measures].[Waste - Lookup Table]
} ON ROWS
FROM
[MyCube]
结果:
我希望这个例子很有用