Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mondrian: calculating filter totals

Tags:

mondrian

mdx

I have this MDX query:

    with member [Measures].[count] as '[Measures].[NUMBER]'
         ** member [Measures].[total] as 'sum({[RECORD_TYPE.VALUES].[All VALUEs].children})' **
         member [Measures].[% records] as '([Measures].[count] / [Measures].[total])', format_string = "0.0%"
   select {[Measures].[count], [Measures].[% records], [Measures].[total]} ON COLUMNS,
  [RECORD_TYPE.VALUE].[1] ON ROWS
    from [RECORDS]
   where Crossjoin({[CITY].[LONDON]}, {([DATE.DATE].[20171101] : [DATE.DATE].[20171130])})

I have found out that this [total] member only counts filtered records by date (records data between 20171101 and 20171130). If I switch this total to:

member [Measures].[total] as 'sum({[DATE.DATE].[All DATEs].children})'

I am getting all records in cube, regardless of city.

I would like this total to be the total number of records for [CITY].[LONDON] in cube, no matter the record type. Could you please tell me how do I do this?

like image 575
Rafael Segovia Avatar asked Nov 07 '22 13:11

Rafael Segovia


1 Answers

I'm not a mondrian expert, but my guess is the following:

  with member [Measures].[count] as '[Measures].[NUMBER]'
         ** member [Measures].[total] as 'sum({[RECORD_TYPE.VALUES].[All VALUEs].children} * [CITY].[LONDON])' **
             member [Measures].[% records] as '([Measures].[count] / [Measures].[total])', format_string = "0.0%"
       select {[Measures].[count], [Measures].[% records], [Measures].[total]} ON COLUMNS,
      [RECORD_TYPE.VALUE].[1] ON ROWS
        from [RECORDS]
       where Crossjoin({[CITY].[LONDON]}, {([DATE.DATE].[20171101] : [DATE.DATE].[20171130])})
like image 197
Danylo Korostil Avatar answered Nov 29 '22 15:11

Danylo Korostil