产品Dimemsion的MDX Getcurrent PricelogID

时间:2015-05-08 09:09:20

标签: mdx

我有桌子:

Table Products ( ProductID , ProductName,..) --Dimemsion
Table PriceLog (PriceLogID, Price, ApplyDate,...) Log the price of product at the event time. - Dimemsion
Table Sale (SaleID, ProductID, PriceLogID,...) --Measure

现在我想对这样的报告进行MDX查询:

ProductID, ProductName, PriceLogID, CountProductSold
1          Tivi       ,10          ,20
1          Tivi       ,11          ,23
2          Phone      ,10          ,55
2          Phone      ,12          ,10

但我的问题是获得PriceLogID和CountProductSold,系统给我一个OutOffMemory错误,因为我有超过10000 PriceLogID

这是我的查询

WITH 
  MEMBER [Measures].[COUNTProductSold] AS 
    Count(Exists([Measures].[Sale],[Products].[ProductID].[ProductID])) 
SELECT 
  [Measures].[COUNTProductSold] ON COLUMNS
 ,
    [Products].[ProductID].[ProductID]*
    [Products].[ProductID].[Product Name]*
    [PriceLog].[PriceLogID].[PriceLogID] ON ROWS
FROM [my cube];

错误:

Exception of type 'System.OutOfMemoryException' was thrown.

2 个答案:

答案 0 :(得分:0)

以下是否适合您?

WITH 
  MEMBER [Measures].[COUNTProductSold] AS 
    Count(
         NonEmpty
              (
              [Products].[ProductID].[ProductID], 
              [Measures].[Sale]
              )
         ) 
SELECT 
    [Measures].[COUNTProductSold] ON COLUMNS,        
    [Products].[ProductID].[ProductID]* [Products].[ProductID].[Product Name]* [PriceLog].[PriceLogID].[PriceLogID] ON ROWS
FROM [my cube];

答案 1 :(得分:0)

我找到了解决方案,因为测量价格日志有超过10000条记录,在计算时,mdx将为每个productID计算10000次。 解决方案是使用NonEmpty函数和子查询。