MDX - 从选定期间获得总额

时间:2016-03-07 09:34:00

标签: ssas mdx

我想计算一个选定时期的百分比值。我不知道如何处理它。

              | Quantity | CalcMember |

January       |     5    |            |

   2015-01-01 |     1    |    20%     |

   2015-01-02 |     2    |    40%     |

   2015-01-03 |     2    |    40%     |

我只需要从第X天到第X天的所选时间段的总和,而不是整个月的计算结果。

问题是汇总计算成员中的已过滤成员。

编辑:我找到了解决方案!

我必须创建一个动态集

CREATE DYNAMIC SET CurrentCube.[SelectedDates] AS [Date].[YearMonth].[Date].Members;

CREATE MEMBER CURRENTCUBE.[Measures].[Percentage] AS 
[Measures].[Qty] / SUM([SelectedDates], [Measures].[Qty]),
format_string = "Percent"

但仅当日期在行中时才有效...

1 个答案:

答案 0 :(得分:0)

使用现有功能

CREATE HIDDEN DYNAMIC SET [SelectedDates] AS
  EXISTING [Date].[YearMonth].[----smallest level of your hierarchy---].Members;

CREATE MEMBER CURRENTCUBE.[Measures].[Percentage] AS 
  [Measures].[Qty] /    // or somethinng like [Original Value] from numeric calculations if you want to do that for multiple measures at once
        Sum 
            ([SelectedDates], [Measures].[Qty]
        );
相关问题