简体   繁体   中英

How to find sum of each group in Hierarchy in MDX

In the example below I want to find sum of each group. Can someone correct my MDX query to get the desired result for GroupCount Column.

with member [GroupCount] as
aggregate([Department].[Department ID].currentmember.parent,
          [Measures].[Pay Frequency])


select {[Department].[Group Name].[all].children*
        [Department].[Department ID].[all].children
       } on rows,
{[Measures].[Pay Frequency],[GroupCount]} on columns
from test

The result I am getting from the above query is:

在此处输入图片说明

However I need the output as :

在此处输入图片说明

Is it like this?

with member [GroupCount] as
(
     [Department].[Group Name].CURRENTMEMBER,
     [Department].[Department ID].[All],
     [Measures].[Pay Frequency]
)
select {[Department].[Group Name].[all].children*
        [Department].[Department ID].[all].children
       } on rows,
{[Measures].[Pay Frequency],[GroupCount]} on  columns
from test;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM