2012-06-14 113 views
0

我希望得到一個產品的到期日期,但是,可能有幾個到期日期爲產品獲得第一部件與MDX

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]}) 

任何幫助嗎?

感謝

回答

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]}) 

您可以添加一個措施,因爲如果需要非空的第二個參數。

+0

太棒了,這正是我一直在尋找,感謝您的幫助! – user1112251