好的,我有一个扁平的层次结构作为数据仓库中多维数据集中的维度表,我需要将一个度量值汇总到层次结构顶部的所有父级。
一些小数据向您展示我正在努力实现的目标......
---------------------------------------------------------
| DimWBSKey | Name | SortableWBS |
|------------|--------------------|---------------------|
| 1 | Recapitalization | 0050 |
| 2 | Recap Child | 0050.0001 |
| 3 | Recap Grandchild | 0050.0001.0002 |
| 4 | Recap GG | 0050.0001.0002.0003 |
| 5 | Recap GG 2 | 0050.0001.0002.0004 |
| 6 | Program Management | 0050.0002 |
| 7 | Program Child | 0050.0002.0002 |
| 8 | Program Grandchild | 0050.0002.0002.0001 |
---------------------------------------------------------
---------------------------
| DimWBSKey | Budget |
|------------|------------|
| 4 | $150,000 |
| 5 | $25,000 |
| 8 | $50,000 |
---------------------------
----------------------------------------------------------------------
| DimWBSKey | Name | SortableWBS | Budget |
|------------|--------------------|---------------------|------------|
| 1 | Recapitalization | 0050 | $225,000 |
| 2 | Recap Child | 0050.0001 | $175,000 |
| 3 | Recap Grandchild | 0050.0001.0002 | $175,000 |
| 4 | Recap GG | 0050.0001.0002.0003 | $150,000 |
| 5 | Recap GG 2 | 0050.0001.0002.0004 | $25,000 |
| 6 | Program Management | 0050.0002 | $50,000 |
| 7 | Program Child | 0050.0002.0002 | $50,000 |
| 8 | Program Grandchild | 0050.0002.0002.0001 | $50,000 |
----------------------------------------------------------------------
如果我只是执行如下的基本MDX查询,我会为所有父母获得NULLS(如预期的那样)。
SELECT {
[Measures].[Budget]
} ON COLUMNS, {
[DimWBS].[SortableWBS].[SortableWBS].MEMBERS
} ON ROWS FROM [G2 Summary]
生成这个:
----------------------------------------------------------------------
| DimWBSKey | Name | SortableWBS | Budget |
|------------|--------------------|---------------------|------------|
| 1 | Recapitalization | 0050 | NULL |
| 2 | Recap Child | 0050.0001 | NULL |
| 3 | Recap Grandchild | 0050.0001.0002 | NULL |
| 4 | Recap GG | 0050.0001.0002.0003 | $150,000 |
| 5 | Recap GG 2 | 0050.0001.0002.0004 | $25,000 |
| 6 | Program Management | 0050.0002 | NULL |
| 7 | Program Child | 0050.0002.0002 | NULL |
| 8 | Program Grandchild | 0050.0002.0002.0001 | $50,000 |
----------------------------------------------------------------------
我尝试过的一些事情已经失败了
如果有帮助,我确实在DimWBS表中有ParentWBSKey,虽然我没有在这里看到它。
所以,我的问题是......在扁平的不规则层次结构中汇总预算措施的最佳方法是什么?