使用多级层次结构生成月份范围

Generating range of months using multi-level hierarchies

我想通过仅选择从 [ComptaPlanId].[ComptaDateDebut][ComptaPlanId].[ComptaDateFin] 的月份来过滤 [ComptaEcriture Date] 的月份,但是由于 [ComptaDateDebut][ComptaDateFin][ComptaEcriture Date].[ComptaEcriture Date].[Month] 不是同一个级别的,bot 也不是同一个维度的,我不知道怎么实现。

如果我可以生成一系列月份,那就太好了。我的尺寸如下:

假设您正在测试 PlanId 不是 All 成员,您可以为此使用 isAll MDX+ 函数。

对于集合,我们将组合Filter function with a Declared function,即使我们可以将它的所有代码都放在过滤器中。它看起来像:

WITH
  FUNCTION inRange(Value _date,Value _start, Value _end) AS _start <= _date AND _date <= _end
  SET myDates as  Filter( [Date].[Date].[Month] as t, inRange(t.current.key, DateTime(2015,6,1), DateTime(2017,1,1)  ) )
SELECT
 myDates on 0
FROM [Cube]

并使用紧凑且更快的版本:

SELECT
 Filter( [Date].[Date].[Month] as t, DateTime(2015,6,1) <= t.current.key AND t.current.key <= DateTime(2017,1,1) ) on 0
FROM [Cube]

使用成员:

WITH
  FUNCTION inRange(Value _date,Value _start, Value _end) AS _start <= _date AND _date <= _end
  SET myDates as  Filter( [Date].[Date].[Month] as t, 
                    inRange(t.current.key, [ComptaDateDebut].currentmember.key, [ComptaDateFin].currentmember.key  ) 
                  )
SELECT
 myDates on 0
FROM [Cube]

您可以使用 contextMember 而不是 currentMember 来检查切片器(FILTER BY 或子选择)