Promedio de sumas en consulta MDX

How can I compute average of sums in MDX? I want to compute sum of spending for each person and then compute an average of it. I have the following query so far, but I believe it gives me wrong result:

WITH MEMBER [Measures].[Average] AS
SELECT [Measures].[Average] ON COLUMNS
( SELECT Measures.cost ON COLUMNS,
{Person.[Last name].MEMBERS}*
{Person.[First name].MEMBERS} ON ROWS
FROM Cube )

Cualquier ayuda sería muy apreciada.

preguntado el 28 de agosto de 12 a las 12:08

2 Respuestas

You just need to put in the first argument of Promedio the set of your persons.

WITH MEMBER [Measures].[Average] AS
    AVG(Person.[Last name].MEMBERS * Person.[First name].MEMBERS, Measures.cost)
SELECT [Measures].[Average] ON COLUMNS

Respondido el 03 de Septiembre de 12 a las 12:09

The result is closer to the right value, but still not there :) The average should be between 100 and 1000, the result was slightly over 4000. - kyooryu

@kyooryu Could you check that there are no unexpected elements in Person.[Last name].MEMBERS? - Benoit

Ah, I copypasted the answer as it was, I did not notice that last name is not crossed with first name. - kyooryu

Try to create a calculated measure for this function like this

IIF (([Measures.cost] > 0), AVG(Person.Members,Measures.cost),null)

Then use this calculated measure in your MDX query

SELECT Person, 'calculated.measure' 

This is only a sample code to illustrate the function.

Respondido 28 ago 12, 13:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.