维度-共享层次维度

单独的时间维度,时间维度本身也是有层次的。

共享加上时间维度

 创建年月表,主键是[年月]

create Table 年月表     
(
年月 nvarchar(10), 
年 int,
季度 int,
月份 int
)



insert into 年月表(年月,年,季度,月份)
select '2018-01',2018,1,1
union all
select '2018-02',2018,1,2
union all
select '2018-03',2018,1,3
union all
select '2018-04',2018,2,4
union all
select '2018-05',2018,2,5
union all
select '2018-06',2018,2,6
union all
select '2018-07',2018,3,7
union all
select '2018-08',2018,3,8
union all
select '2018-09',2018,3,9
union all
select '2018-10',2018,4,10
union all
select '2018-11',2018,4,11
union all
select '2018-12',2018,4,12



insert into 年月表(年月,年,季度,月份)
select '2019-01',2019,1,1
union all
select '2019-02',2019,1,2
union all
select '2019-03',2019,1,3
union all
select '2019-04',2019,2,4
union all
select '2019-05',2019,2,5
union all
select '2019-06',2019,2,6
union all
select '2019-07',2019,3,7
union all
select '2019-08',2019,3,8
union all
select '2019-09',2019,3,9
union all
select '2019-10',2019,4,10
union all
select '2019-11',2019,4,11
union all
select '2019-12',2019,4,12

共享【时间维度】的主键就是年月了

其它Cube调用共享维度的时候外键也必须是这个颗粒度最细的年月

注意,时间维度 年的uniqueMembers是true,季度和月份的uniqueMembers都是false,表示季度同为1季度但是因为年份不一样也是唯一的。

 

修改后Saiku展示的效果如下:

原文地址:https://www.cnblogs.com/Bruce_H21/p/10518570.html