Ahmed Tanvir
Ahmed Tanvir

Reputation: 197

Regarding Max function in MDX

I have a fact table with structure: (objectid, fromLoc, toLoc, duration).

I need the equivalent MDX for the following SQL:

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:

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

Please help me by providing the correct MDX which can answer the queries like the above SQL.

Upvotes: 1

Views: 1058

Answers (1)

Benoit
Benoit

Reputation: 1993

You have have to use the max function like this:

max(the set of your objectids, [Measures].[Duration])

Upvotes: 1

Related Questions