原始 MDX 语句
SELECT { [Measures].[Seat Use Count]* [Dim Date].[Date Name].[Date Name].ALLMEMBERS }
ON COLUMNS, { ([BG Info].[BG Name].[BG Name].ALLMEMBERS ) }
ON ROWS FROM ( SELECT ( [Dim Date].[Date Name].&[2016-07-13T00:00:00] :
[Dim Date].[Date Name].&[2016-07-14T00:00:00] )
ON COLUMNS FROM [Office Space])
希望把2016-07-13T00:00:00 换成动态的 获取 昨天,2016-07-14T00:00:00动态获取今天。
使用 StrToMember 函数。
eg:
WITH MEMBER MEASURES.BGUseCount AS IIF([Measures].[Seat Use Count]>0,[Measures].[Seat Use Count], 0)
MEMBER MEASURES.BGODCUseCount AS IIF((MEASURES.BGUseCount,[Staff Type].[Staff Type Other Name].&[外包])>0,(MEASURES.BGUseCount,[Staff Type].[Staff Type Other Name].&[外包]),0)
MEMBER MEASURES.BGFormalUseCount AS IIF((MEASURES.BGUseCount,[Staff Type].[Staff Type Other Name].&[正式])>0,(MEASURES.BGUseCount,[Staff Type].[Staff Type Other Name].&[正式]),0)
SELECT {
MEASURES.BGUseCount,MEASURES.BGODCUseCount, MEASURES.BGFormalUseCount
}
ON COLUMNS,
{ ([Staff Dept].[BG Name].[BG Name].ALLMEMBERS *[Staff Dept].[Dept Name].[Dept Name].ALLMEMBERS ) }
ON ROWS
FROM (
SELECT ( { StrToMember("[Dim Date].[Date Name].&["+ Format( DateAdd ('d',-1,now()),"yyyy-MM-ddT00:00:00") +"]") } ) ON COLUMNS FROM [Office Space]) WHERE
( StrToMember("[Dim Date].[Date Name].&["+ Format( DateAdd ('d',-1,now()),"yyyy-MM-ddT00:00:00") +"]") )