获得MDX的第一个成员

时间:2012-06-14 18:20:17

标签: mdx member

我想获得产品的到期日期,但是,产品可能有几个到期日

ProductID  | ExpDate | Qty
    1         FY12     1000
    2         FY12     1000
    2         FY14     1000
    3         FY13     1000
    3         FY15     1000

正如您所看到的,产品有几个日期,但我只想要第一个ExpDate。

这是我目前的查询

SELECT NON EMTPY
([Product].[ProductID].[ProductID].MEMBERS *
[Primary Expiration Date].[Primary Expiration Year].[Primary Expiration Year].MEMBERS) on ROWS,
NON EMTPY ([Measures].[Qty]) on columns
FROM Sales_Market
WHERE(
{[Primary Expiration Date].[Primary Expiration Date Hierarchy].[Primary Expiration Quarter].&[FY12-Q4], 
[Primary Expiration Date].[Primary Expiration Date Hierarchy].[Primary Expiration Year].&[FY13], 
[Primary Expiration Date].[Primary Expiration Date Hierarchy].[Primary Expiration Year].&[FY14], 
[Primary Expiration Date].[Primary Expiration Date Hierarchy].[Primary Expiration Year].&[FY15]})

任何帮助?

由于

1 个答案:

答案 0 :(得分:2)

您可以尝试此查询:

SELECT NON EMTPY
Generate([Product].[ProductID].[ProductID].MEMBERS, Subset(NonEmpty({[Product].CurrentMember} * [Primary Expiration Date].[Primary Expiration Year].[Primary Expiration Year].MEMBERS), 0, 1)) on ROWS,
NON EMTPY ([Measures].[Qty]) on columns
FROM Sales_Market
WHERE(
{[Primary Expiration Date].[Primary Expiration Date Hierarchy].[Primary Expiration Quarter].&[FY12-Q4], 
[Primary Expiration Date].[Primary Expiration Date Hierarchy].[Primary Expiration Year].&[FY13], 
[Primary Expiration Date].[Primary Expiration Date Hierarchy].[Primary Expiration Year].&[FY14], 
[Primary Expiration Date].[Primary Expiration Date Hierarchy].[Primary Expiration Year].&[FY15]})

如有必要,您可以添加一个度量作为NonEmpty的第二个参数。