Sql server 2008 r2 基于另一列的值动态更改MDX查询的一列的值

Sql server 2008 r2 基于另一列的值动态更改MDX查询的一列的值,sql-server-2008-r2,ssas,mdx,Sql Server 2008 R2,Ssas,Mdx,我正在处理一个MDX查询。我希望其中一列的值根据另一列的值动态更改。我写的问题是:- WITH MEMBER [Measures].[FName] AS [Loyalty Cards].[Grouped Cards].CurrentMember.Properties("Full Name") MEMBER [Measures].[RegShop]AS [Loyalty Cards].[Grouped Cards].CurrentMember.Properties("Reg Shop

我正在处理一个MDX查询。我希望其中一列的值根据另一列的值动态更改。我写的问题是:-

WITH 
MEMBER  [Measures].[FName]  AS [Loyalty Cards].[Grouped    Cards].CurrentMember.Properties("Full Name")
MEMBER  [Measures].[RegShop]AS [Loyalty Cards].[Grouped Cards].CurrentMember.Properties("Reg Shop")
MEMBER  [Measures].[Date Of First Bet] AS [Loyalty Cards].[Grouped Cards].CurrentMember.Properties("First Use Date")
MEMBER  [Measures].[MostUsedShop] AS [Loyalty Cards].[Grouped Cards].CurrentMember.Properties("Most Used Shop")
MEMBER  [Measures].[Givex_mem_Num]AS [Loyalty Cards].[Grouped Cards].CurrentMember.Properties("KeyCardNumbers")   

SELECT {
 [Measures].[Givex_mem_Num]
 ,[Measures].[FName]
 ,[Measures].[RegShop]
 ,[Measures].[Date Of First Bet]
 ,[Measures].[MostUsedShop]
 ,[Measures].[Slip Count]
 ,[Measures].[Slip Stake]
 ,[Measures].[SlipGrossWin]
 ,[Measures].[Average Stake Per Slip]
 }ON COLUMNS,
 {
   NONEMPTY([Loyalty Cards].[Grouped Cards].[KeyCardNumbers], [Measures].[Total     Turnover])
 }
  ON ROWS
FROM [RetailCube]
WHERE 
  [Time Slice].[Timeslice].[TimesliceID].&[LIVE2DT]
我从上面得到的示例输出是:

现在,我希望第一个下注列的日期根据
Givex\u mem\u num
的值进行更改(特别是对于第一行,它是=-99)。 有人能帮我解决这个问题吗?我试过几种方法

直到最近,我修改了查询的第一部分,以便:

WITH 
  MEMBER  [Measures].[FName]  AS [Loyalty Cards].[Grouped    Cards].CurrentMember.Properties("Full Name")
  MEMBER  [Measures].[RegShop]AS [Loyalty Cards].[Grouped Cards].CurrentMember.Properties("Reg Shop")
  MEMBER  [Measures].[NullVal] AS NULL
  MEMBER  [Measures].[Date Of First Bet] AS [Loyalty Cards].[Grouped Cards].CurrentMember.Properties("First Use Date")
  MEMBER  [Measures].[MostUsedShop] AS [Loyalty Cards].[Grouped Cards].CurrentMember.Properties("Most Used Shop")
  MEMBER  [Measures].[Givex_mem_Num] AS (
   IIF( [Loyalty Cards].[Grouped Cards].CurrentMember.Properties("KeyCardNumbers")=-99,[Measures].[Date Of First Bet] ='A',[Measures].[Date Of First Bet])
  )         

SELECT {
 [Measures].[Givex_mem_Num]
,[Measures].[FName]
,[Measures].[RegShop]
,[Measures].[Date Of First Bet]
,[Measures].[MostUsedShop]
,[Measures].[Slip Count]
,[Measures].[Slip Stake]
,[Measures].[SlipGrossWin]
,[Measures].[Average Stake Per Slip]
}ON COLUMNS,
但这会将Givex_mem_num值更改为第一次下注日期的值,这是不需要的。
如果您需要更多详细信息,请发表意见。

如果您在
WITH member
子句中定义了单个成员的值,则无法在此处更改其他成员。您应该向
WITH
子句添加另一个成员,如

MEMBER [Measures].[Calc Date Of First Bet] AS
       IIf([Measures].[Givex_mem_Num] = -99, 'A', [Measures].[Date Of First Bet])

然后使用该成员,而不是列的度量值列表中的
[Measures].[首次下注日期]
。当然,您可以随意重命名它,它只是应该不同于所有现有的度量名称

谢谢Frank,我在相同的度量定义中进行了此修改,并且它正在工作:)