MDX-如何“汇总”已过滤的结果集

时间:2020-02-07 11:26:27

标签: filter aggregate mdx

我正在努力确定适当的MDX查询语法,以便在移动过滤器后返回预期结果集,以支持高级嵌套过滤。

下面的查询是今天生成的内容,屏幕截图显示了结果。是否有人对基于以下查询的屏幕截图所述如何获得所需结果有任何见识。

注意-我认为过滤器需要保留在原处,以支持嵌套的复杂过滤器。即((A = 1 OR B <1)AND(A> 1 OR C = 2))|| (B = 3 AND C = 4)

  WITH
  SET AllRowsSet AS
    {
      Filter
      (
        NonEmpty
        (
            called_cities.[called_city].Children*
            called_countries.[called_country_name].Children*
            billing_months.[billing_month].Children*
            sources_pivot_v1.[source_name_l1].Children*
            products_pivot.[product_name_l1].Children*
            products_pivot.[product_name_l2].Children
            ,{
                [Measures].[actual_duration]
                ,[Measures].[amount]
            }
        )
       ,
        billing_months.[billing_month].CurrentMember.Member_Caption = '201805'
        AND products_pivot.[product_name_l1].CurrentMember.Member_Caption = 'Usage'
        AND products_pivot.[product_name_l2].CurrentMember.Member_Caption = 'LD International'
        AND called_countries.[called_country_name].CurrentMember.Member_Caption <> 'TEST_NULL'
        AND (
            sources_pivot_v1.[source_name_l1].CurrentMember.Member_Caption = 'Company for Joint'
            OR sources_pivot_v1.[source_name_l1].CurrentMember.Member_Caption = 'Cisco Call Manager'
        )
      )
    }
  MEMBER [Measures].totalrows AS AllRowsSet.Count
  MEMBER [Measures].[called_city] AS called_cities.[called_city].CurrentMember.Member_Caption
  MEMBER [Measures].[called_country_name] AS called_countries.[called_country_name].CurrentMember.Member_Caption
  MEMBER [Measures].[billing_month] AS billing_months.[billing_month].CurrentMember.Member_Caption
  MEMBER [Measures].[source_name_l1] AS sources_pivot_v1.[source_name_l1].CurrentMember.Member_Caption
  MEMBER [Measures].[product_name_l1] AS products_pivot.[product_name_l1].CurrentMember.Member_Caption
  MEMBER [Measures].[product_name_l2] AS products_pivot.[product_name_l2].CurrentMember.Member_Caption

SELECT
  {
    [Measures].[actual_duration]
   ,[Measures].[amount]
   ,[Measures].totalrows
   ,[Measures].[called_city]
   ,[Measures].[called_country_name]
   ,[Measures].[billing_month]
   ,[Measures].[source_name_l1]
   ,[Measures].[product_name_l1]
   ,[Measures].[product_name_l2]
  } ON COLUMNS
 ,SubSet
  (
    Order
    (
      Filter
      (
        NonEmpty
        (
            called_cities.[called_city].Children*
            called_countries.[called_country_name].Children*
            billing_months.[billing_month].Children*
            sources_pivot_v1.[source_name_l1].Children*
            products_pivot.[product_name_l1].Children*
            products_pivot.[product_name_l2].Children
         ,{
            [Measures].[actual_duration]
           ,[Measures].[amount]
          }
        )
       ,
        billing_months.[billing_month].CurrentMember.Member_Caption = '201805'
        AND products_pivot.[product_name_l1].CurrentMember.Member_Caption = 'Usage'
        AND products_pivot.[product_name_l2].CurrentMember.Member_Caption = 'LD International'
        AND called_countries.[called_country_name].CurrentMember.Member_Caption <> 'TEST_NULL'
        AND (
            sources_pivot_v1.[source_name_l1].CurrentMember.Member_Caption = 'Company for Joint'
            OR sources_pivot_v1.[source_name_l1].CurrentMember.Member_Caption = 'Cisco Call Manager'
        )
      )
     ,[Measures].[amount]
     ,BDESC
    )
   ,0
   ,250
  ) ON ROWS
FROM
(
  SELECT {billing_months.[v1_disabled].[v1_disabled].&[0]} ON 0 FROM calls
);

enter image description here

1 个答案:

答案 0 :(得分:0)

要汇总,您可以- 1.将ON ROWS集移到WITH子句中 2.将其包装在汇总中 3.您将需要在多维数据集中找到一个“备用”维度,该维度未在此查询中用于创建此新的自定义MEMBER:

class Animal {
  constructor(nombre) {
    this._nombre = nombre
  }
  get nombre() {
    return this._nombre
  }
}
scooby = new Animal('Scooby');

console.log( 'scooby.nombre =', scooby.nombre )