我正在处理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]
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_mem_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值更改为第一次下注日期的值,而不需要。 如果您需要更多详细信息,请发表评论
答案 0 :(得分:0)
您可以在WITH MEMBER
子句中定义单个成员的值,但不能更改其他成员。您应该将另一个成员添加到WITH
子句中,如
MEMBER [Measures].[Calc Date Of First Bet] AS
IIf([Measures].[Givex_mem_Num] = -99, 'A', [Measures].[Date Of First Bet])
然后在列的度量列表中使用该成员而不是[Measures].[Date Of First Bet]
。当然,您可以按照自己的意愿重命名,它应该与所有现有的度量名称不同。