# [Mondrian] How to dynamically group multiple range on dimension

Tom Barber tom at analytical-labs.com
Tue Mar 15 20:27:06 EDT 2016

```Hi

I'd normally create another "bucket" column in my dimension that is
populated by the value you want 20-29 or whatever. Then just create a 2nd
hierarchy in the schema that uses that column instead of the actual year.

Tom
On 16 Mar 2016 00:15, "Selina Tech" <swucareer99 at gmail.com> wrote:

> Dear All:
>   I have a question on "How to dynamically group multiple range on
> dimension".
>
>  I have a dimension called age_dim and a measure called sum_count which is
> sum of all count.  I have following two MDX query and get same result
> listing all the sum_count for different ages.
>
> SELECT
> NON EMPTY {[Measures].[sum_count]} ON COLUMNS,
> NON EMPTY {[age_dim].[count_hiera].[age].Members } ON ROWS
> FROM [my_cube]
>
>
> SELECT
> NON EMPTY {[Measures].[sum_count]} ON COLUMNS,
> NON EMPTY {
> [age_dim].[count_hiera].[age].&[20] : [age_dim].[count_hiera].[age].&[29],
> [age_dim].[count_hiera].[age].&[30] : [age_dim].[count_hiera].[age].&[39],
> [age_dim].[count_hiera].[age].&[40] : [age_dim].[count_hiera].[age].&[49]
>  } ON ROWS
> FROM [my_cube]
>
> age   sum_count
> 21     40
> 25     15
> 27     25
> 35     30
> 38     20
> 45     20
> 47     10
>
>
> ----------------
> However I like to get table below which the sum_count can be grouped by
> range of age dimension. Any Help would be great!
>
> ------------------
> age   sum_count
> 20-29     80
> 30-39     50
> 40-49     30
>
>
> _______________________________________________
> Mondrian mailing list
> Mondrian at pentaho.org
> http://lists.pentaho.org/mailman/listinfo/mondrian
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20160316/fce37176/attachment.html
```