Tuple 函式會藉由解析 Tuple 的字串表示,從集合擷取 Tuple 或擷取 Tuple。
Tuple 函式,例如成員函式和 set 函式,對於交涉 Analysis Services 中找到的多維度結構而言,是不可或缺的。
MDX、 Current (MDX)、 Item (Tuple) 和 StrToTuple (MDX ) 中有三個 Tuple 函式。 下列範例查詢示範如何使用它們:
WITH
//Creates a set of tuples consisting of Years and Countries
SET MyTuples AS [Date].[Calendar Year].[Calendar Year].MEMBERS * [Customer].[Country].[Country].MEMBERS
//Returns a string representation of that set using the Current and Generate functions
MEMBER MEASURES.CURRENTDEMO AS GENERATE(MyTuples, TUPLETOSTR(MyTuples.CURRENT), ", ")
//Retrieves the fourth tuple from that set and displays it as a string
MEMBER MEASURES.ITEMDEMO AS TUPLETOSTR(MyTuples.ITEM(3))
//Creates a tuple consisting of the measure Internet Sales Amount and the country Australia from a string
MEMBER MEASURES.STRTOTUPLEDEMO AS STRTOTUPLE("([Measures].[Internet Sales Amount]" + ", [Customer].[Country].&[Australia])")
SELECT{MEASURES.CURRENTDEMO,MEASURES.ITEMDEMO,MEASURES.STRTOTUPLEDEMO} ON COLUMNS
FROM [Adventure Works]