我想检查月份的数量,并根据该划分一定数量。问题是此代码始终默认为SHA
语句。谁能发现这个问题?感谢。
var myname = "bob";
var thevar = "";
var varobj = {tvar: "myname"};
var syncvar = function() {
thevar = eval(varobj.tvar);
};
syncvar();
alert(thevar); // bob
myname = "eve";
syncvar();
alert(thevar); // eve
答案 0 :(得分:1)
尝试在CASE
语句的条件下与成员的值进行比较。目前,您正在比较[Date].[Calendar Month Number Of Year]
中未被视为数字表达式的成员mdx
,并将其与数字表达式(2,4,...)进行比较。
也许以下效果更好:
CREATE MEMBER CURRENTCUBE.[Measures].[SBBD]
AS case [Date].[Calendar Month Number Of Year].CURRENTMEMBER.MEMBER_VALUE
when 2 then [Measures].[SB]/28
when 4 then [Measures].[SB]/30
when 6 then [Measures].[SB]/30
when 9 then [Measures].[SB]/30
when 11 then [Measures].[SB]/30
else [Measures].[SB]/31
end,
FORMAT_STRING = "Standard",
VISIBLE = 1 , ASSOCIATED_MEASURE_GROUP = 'LB';
我更倾向于最初创建一个度量[Measures].[NumOfMonth]
,然后将其提供给案例(这样可能会更快地分成两个):
CREATE MEMBER CURRENTCUBE.[Measures].[NumOfMonth]
AS [Date].[Calendar Month Number Of Year].CURRENTMEMBER.MEMBER_VALUE,
FORMAT_STRING = "Standard",
VISIBLE = 0 , ASSOCIATED_MEASURE_GROUP = 'LB';
CREATE MEMBER CURRENTCUBE.[Measures].[SBBD]
AS case [Measures].[NumOfMonth]
when 2 then [Measures].[SB]/28
when 4 then [Measures].[SB]/30
when 6 then [Measures].[SB]/30
when 9 then [Measures].[SB]/30
when 11 then [Measures].[SB]/30
else [Measures].[SB]/31
end,
FORMAT_STRING = "Standard",
VISIBLE = 1 , ASSOCIATED_MEASURE_GROUP = 'LB';
硬币的其他方面
您可以比较成员,而不是担心价值观。案例的条件应使用currentmember
函数,并将成员替换为成员:
CREATE MEMBER CURRENTCUBE.[Measures].[SBBD]
AS CASE [Date].[Calendar Month Number Of Year].CURRENTMEMBER
WHEN [Date].[Calendar Month Number Of Year].[2] then [Measures].[SB]/28
WHEN [Date].[Calendar Month Number Of Year].[4] THEN [Measures].[SB]/30
WHEN [Date].[Calendar Month Number Of Year].[6] THEN [Measures].[SB]/30
WHEN [Date].[Calendar Month Number Of Year].[9] THEN [Measures].[SB]/30
WHEN [Date].[Calendar Month Number Of Year].[11] THEN [Measures].[SB]/30
ELSE[Measures].[SB]/31
END,
FORMAT_STRING = "Standard",
VISIBLE = 1 , ASSOCIATED_MEASURE_GROUP = 'LB';