Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Count产品在MDX查询中售出_Mdx - Fatal编程技术网

Count产品在MDX查询中售出

Count产品在MDX查询中售出,mdx,Mdx,我的MDX查询为 SELECT {[Measures].[SaleAMT]} ON COLUMNS ,NON EMPTY [Account Date13h].[Date].&[2015-01-01T00:00:00] : [Account Date13h].[Date].&[2015-05-05T00:00:00] ON ROWS FROM [Sale_Period_report]; 我想退回已售出产品的数量,如下所示: Date

我的MDX查询为

SELECT 
  {[Measures].[SaleAMT]} ON COLUMNS
 ,NON EMPTY 
      [Account Date13h].[Date].&[2015-01-01T00:00:00]
    : 
      [Account Date13h].[Date].&[2015-05-05T00:00:00] ON ROWS
FROM [Sale_Period_report];
我想退回已售出产品的数量,如下所示:

Date         SaleAmt    ProductSold
2015-04-01   20.000     150
2015-04-02   36.212     650
2015-04-05   10.333     65

如果您有一个衡量销售产品的指标,请使用此查询:

SELECT 
    {[Measures].[SaleAMT], [Measures].[ProductsSold]}  ON COLUMNS,

    NON EMPTY {[Account Date13h].[Date].&[2015-01-01T00:00:00]:
               [Account Date13h].[Date].&[2015-05-05T00:00:00]
              } ON ROWS
    FROM [Sale_Period_report]
如果您没有这样的度量,我将假设您的多维数据集中有一个产品层次结构,如
products.Product

在这种情况下,您必须创建一个计算成员,该成员将为您提供计数

WITH MEMBER [Measures].[ProductsSold] AS
COUNT(
        EXISTS(Products.Product.CHILDREN, 
        {[Account Date13h].[Date].&[2015-01-01T00:00:00]:[Account Date13h].[Date].&[2015-05-05T00:00:00]},
        "Sales"       
     )
然后是一样的:

SELECT 
    {[Measures].[SaleAMT], [Measures].[ProductsSold]}  ON COLUMNS,

    NON EMPTY {[Account Date13h].[Date].&[2015-01-01T00:00:00]:
               [Account Date13h].[Date].&[2015-05-05T00:00:00]
              } ON ROWS
    FROM [Sale_Period_report]
我假设您有一个名为
Sales
的度量值组

为了得到更好的答案,你必须提供更多的细节


希望有帮助

AdvWrks
相比,
计数
现有的
和交叉连接的组合似乎给了我一个可变的结果-这个结果实际上意味着我有点不确定:

WITH  
  MEMBER [Measures].[Count] AS 
    Count
    (
      (EXISTING 
          [Product].[Product Categories].[Product]
        * 
          [Measures].[Internet Sales Amount])
    ) 
SELECT 
  {
    [Measures].[Internet Sales Amount]
   ,[Measures].[Count]
  } ON COLUMNS
 ,
    [Date].[Calendar].[Date].&[20070701]
  : 
    [Date].[Calendar].[Date].&[20070731] ON ROWS
FROM [Adventure Works];
因此适合您的立方体,它可能看起来像:

WITH  
  MEMBER [Measures].[ProductsSold] AS 
    Count
    (
      (EXISTING 
          Products.Product.members
        * 
          [Measures].[SaleAMT])
    ) 
SELECT 
  {
    [Measures].[SaleAMT]
   ,[Measures].[ProductsSold]
  } ON COLUMNS
 ,NON EMPTY 
    {
        [Account Date13h].[Date].&[2015-01-01T00:00:00]
      : 
        [Account Date13h].[Date].&[2015-05-05T00:00:00]
    } ON ROWS
FROM [Sale_Period_report];

我使用此查询和OLAP正确返回我想要的内容

您是否有提供销售产品数量的度量?我们是否应该假设ProductSeld是一个度量值?您的多维数据集中是否有度量值
ProductSeld
?多维数据集中的产品维度是什么?目前我们无法提供帮助,因为您需要在问题中提供完整的信息。您的查询将为所有行返回相同的结果。我使用这个查询:将成员[Measures].[ProductsSold]作为计数(EXISTS(Products.Product.CHILDREN,{[Account Date13h].[Date].&[2015-01-01T00:00:00]:[Account Date13h].[Date].[2015-05-05T00:00:00],“Sales”)(支持)我更倾向于使用
现有的
而不是
存在的

WITH MEMBER [Measures].[ProductsSold] AS
    COUNT(NonEmpty([AccSetting].[AccID].[AccID].ALLMEMBERS, [Measures].[SaleAMT]))