Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Max function in MDX query

$
0
0
I have a fact table with structure:
Code:

(objectid, fromLoc, toLoc, duration)
I need the equivalent MDX for the following SQL:
Code:

select fromLoc, toLoc, max(duration) from fact group by fromLoc, toLoc;
I tried with the following MDX but it's showing wrong results. It's showing sum(duration) instead of showing max value for each grouping:

Code:

WITH
  MEMBER [Measures].[MaxValue] AS
  max([Measures].[Duration]) 
-- Also tried max(FromLoc.members, [Measures].[Duration])
-- Also tried  max(Object.objectid.members, [Measures].[Duration])
 select FromLoc.members on axis(1),
toLoc.members  on axis(0)
from [cube1]
where [Measures].[MaxValue]

In all cases it shows the same result which is the sum of duration per group.
Please help me by providing the correct MDX which can answer the queries like the above SQL.

Viewing all articles
Browse latest Browse all 13329

Trending Articles