Your second term of the cross join for the rows (ORDER(TOPCOUNT(...))
) is not aware of the first ([Customer].[DEPT].[DEPT]
). You should use Generate
for this, as it loops over the departments, and thus allows you to put the current department into the first argument of the TOPCOUNT
:
SELECT
NON EMPTY { [Measures].[Amount] } ON COLUMNS ,
NON EMPTY
Generate([Customer].[DEPT].[DEPT],
TOPCOUNT({[Customer].[DEPT].CURRENTMEMBER}
*
[Customer].[Customer].[Customer],
25,
[Measures].[Amount]
)
)
FROM [cube]
Also note that you do not need to order the result of TOPCOUNT
descending, it is already ordered this way.