스칼라 식 사용Using Scalar Expressions

적용 대상:예SQL Server Analysis Services아니요Azure Analysis ServicesAPPLIES TO:yesSQL Server Analysis ServicesnoAzure Analysis Services

MDX에서 스칼라 식은 계산 시 계산 컨텍스트 내에서 단일 값을 반환하는 MDX 구문의 한 요소입니다.In Multidimensional Expressions (MDX), a scalar expression is an element of MDX syntax that, when evaluated, returns a single value within the context of evaluation.

스칼라 식은 MDX에 문자열, 숫자 및 날짜 식을 포함합니다.Scalar expressions include string, numeric, and date expressions in MDX.

일반적으로 스칼라 식은 계산 멤버 정의에 사용됩니다. 계산 멤버는 스칼라 값을 반환해야 합니다.Scalar expressions are typically used in calculated member definitions, as calculated members must return a scalar value. 다음 쿼리에서는 서로 다른 유형의 스칼라 식을 사용하는 Measures 차원의 계산 멤버 예를 보여 줍니다.The following query shows examples of calculated members on the Measures dimension that use different types of scalar expression:

WITH

MEMBER MEASURES.NumericValue AS 10

MEMBER MEASURES.NumericExpression AS 10 + 10

MEMBER MEASURES.NumericExpressionBasedOnMeasure AS [Measures].[Internet Sales Amount] + 10

MEMBER MEASURES.StringValue AS "10"

MEMBER MEASURES.ConcatenatedString AS "10" + "10"

MEMBER MEASURES.StringFunction AS MEASURES.CURRENTMEMBER.NAME

MEMBER MEASURES.TodaysDate AS NOW()

SELECT

{MEASURES.NumericValue,MEASURES.NumericExpression,MEASURES.NumericExpressionBasedOnMeasure,

MEASURES.StringValue, MEASURES.ConcatenatedString, MEASURES.StringFunction, MEASURES.TodaysDate}

ON COLUMNS

FROM [Adventure Works]

계산 측정값 또는 기타 측정값에서 반환할 수 있는 유일한 데이터 형식은 OLE Variant입니다.The only data type that a measure, calculated or otherwise, can return is the OLE Variant type. 따라서 예상하는 동작을 가져오도록 측정값을 특정 유형으로 캐스팅해야 할 경우도 있습니다.Therefore, sometimes you might need to cast a measure value to a particular type to receive the behavior you expect. 다음 쿼리에서는 이러한 예를 보여 줍니다.The following query shows an example of this:

WITH  
//Two calculated measures that return strings  
MEMBER MEASURES.NumericString1 AS "10"  
MEMBER MEASURES.NumericString2 AS "10"  
//In this case, the + operator acts to concatenate the strings  
MEMBER MEASURES.Concatenation AS MEASURES.NumericString1 + MEASURES.NumericString2  
//Casting one value to an integer with the CINT function causes the second measure  
//to be treated as an integer too, so that the + operator now acts to add the values  
MEMBER MEASURES.Addition AS CINT(MEASURES.NumericString1) + MEASURES.NumericString2  
SELECT  
{MEASURES.NumericString1,MEASURES.NumericString2,MEASURES.Concatenation,MEASURES.Addition }  
ON COLUMNS  
FROM [Adventure Works]  

관련 항목:See Also

식 ( Mdx)Expressions (MDX)