我是MDX查询和寻求帮助的初学者。
我需要根据以下要求创建角色: 我有度量:卡路里 和两个维度:人员和方向
表格如下:
id pid direction calories
1 1 In 20
2 1 In 30
3 1 Out 50
4 2 In 10
5 2 Out 60
6 2 Out 70
7 3 In 20
8 3 In 25
9 3 Out 35
10 4 In 20
11 4 Out 40
我想在必须访问的多维数据集中创建角色:
显示结果的查询是:
with
set [person1] as { { [person].[pid].&[1], [person].[pid].&[2]} * [direction].[direction].&[In] }
set [person2] as { { [person].[pid].&[3]} * [direction].[direction].&[Out] }
set [person3] as { { [person].[pid].&[4]} * {[direction].[direction].&[Out], [direction].[direction].&[In]} }
set [p] as {[person1], [person2], [person3]}
select non empty {measure.calories} on columns,
{[p]} on rows
from [CUBE]
它工作正常。