문자열 함수 사용
MDX(다차원 식)의 거의 모든 개체에서 문자열 함수를 사용할 수 있습니다. 저장 프로시저에서는 주로 문자열 함수를 사용하여 개체를 문자열 표현으로 변환합니다. 또한 값을 반환하기 위해 문자열 함수를 사용하여 개체에 대한 문자열 식을 평가합니다.
가장 널리 사용되는 문자열 함수는 Name 및 Uniquename입니다. 이러한 함수는 각각 개체의 이름과 고유 이름을 반환합니다. 이러한 함수는 대개 함수가 반환하는 멤버를 찾기 위해 계산을 디버깅할 때 사용됩니다.
예
다음 예제 쿼리에서는 이러한 함수를 사용하는 방법을 보여 줍니다.
WITH
//Returns the name of the current Product on rows
MEMBER [Measures].[ProductName] AS [Product].[Product].CurrentMember.Name
//Returns the uniquename of the current Product on rows
MEMBER [Measures].[ProductUniqueName] AS [Product].[Product].CurrentMember.Uniquename
//Returns the name of the Product dimension
MEMBER [Measures].[ProductDimensionName] AS [Product].Name
SELECT {[Measures].[ProductName],[Measures].[ProductUniqueName],[Measures].[ProductDimensionName]}
ON COLUMNS,
[Product].[Product].MEMBERS ON ROWS
FROM [Adventure Works]
Generate 함수를 사용하여 집합의 모든 멤버에서 문자열 함수를 실행하고 결과를 연결할 수 있습니다. 또한 이 함수는 계산을 디버깅할 때 유용할 수 있습니다. 사용자는 이 함수를 사용하여 집합의 내용을 시각화할 수 있습니다. 다음 예제에서는 이러한 방식으로 사용하는 방법을 보여줍니다.
WITH
//Returns the names of the current Product and its ancestors up to the All Member
MEMBER [Measures].[AncestorNames] AS
GENERATE(
ASCENDANTS([Product].[Product Categories].CurrentMember)
, [Product].[Product Categories].CurrentMember.Name, ", ")
SELECT
{[Measures].[AncestorNames]}
ON COLUMNS,
[Product].[Product Categories].MEMBERS ON ROWS
FROM [Adventure Works]
널리 사용되는 문자열 함수의 또 다른 그룹은 개체의 고유 이름을 포함하는 문자열을 캐스팅하거나 개체 자체에 개체로 확인되는 식을 캐스팅할 수 있는 그룹입니다. 다음 예제 쿼리는 StrToMember 및 StrToSet 함수가 이 작업을 수행하는 방법을 보여 줍니다.
SELECT
{StrToMember("[Measures].[Inter" + "net Sales Amount]")}
ON COLUMNS,
StrToSet("{
[Product].[Product Categories].[Category].&[3],
[Product].[Product Categories].[Product].&[477],
[Product].[Product Categories].[Product].&[788],
[Product].[Product Categories].[Product].&[708],
[Product].[Product Categories].[Product].&[711]
}")
ON ROWS
FROM [Adventure Works]
참고 항목
StrToMember 및 StrToSet 함수는 주의해서 사용해야 합니다. 계산 정의 내에서 사용되는 경우 쿼리 성능이 저하할 수 있습니다.
참고 항목
생성(MDX)
이름(MDX)
UniqueName(MDX)
함수(MDX 구문)
저장 프로시저 사용(MDX)
StrToMember(MDX)
StrToSet(MDX)