0

我有以下 SQL 查询,我正在尝试将其转换为 MDX:

select avg(skucount)
from
(
SELECT count(distinct [SKUCode]) as skucount

      --,[SHOPCODE_WITHOUT_DIST]

  FROM [HFPL_DW].[dbo].[FactSecondarySales]
  where DISTCODE in
  (
  SELECT [DISTRIBUTORCODE]
  FROM [HFPL_DW].[dbo].[DimDistHierarchy]
  where REGION = 'KARACHI'
  )
  and month(saledate) = 7 and year(saledate) = 2018 
  group by [SHOPCODE_WITHOUT_DIST]

  ) as inner_query

内部查询返回每个店铺销售的 SKU 数量(使用“Group by ShopCode”实现)

首先,我尝试将内部查询转换为 MDX,我尝试了以下方法:

WITH MEMBER [Measures].[SKU Count] AS
    COUNT( NonEmpty( {  [Product Hierarchy].[SKU].[SKU].Members }, ( [Shop Hierarchy].[SHOPCODE WITHOUT DIST] ) )   )
SELECT
    {
        [Measures].[SKU Count]
    } ON COLUMNS,
    NonEmpty(
        { [Product Hierarchy].[SKU].[SKU].Members },
        ([Shop Hierarchy].[SHOPCODE WITHOUT DIST] )
    ) ON ROWS
FROM
    [Consolidated Sales]
    where(
    [Time Analysis].[Month].&[2018-07-01T00:00:00],

[Distribution Hierarchy].[DISTRIBUTORCODE].&[1002]
)

参考:https ://social.msdn.microsoft.com/Forums/sqlserver/en-US/51988607-78cc-4520-88db-c6d3e99dd1fc/mdx-to-count-the-number-of-members-in-a-基于维度的另一个维度?forum=sqlanalysisservices

它没有返回任何东西。

请帮助我实现平均 SKU 销售量(外部查询)、每家商店销售的 SKU 数量(内部查询)的期望输出

4

0 回答 0