开发者

MDX and AVG function

开发者 https://www.devze.com 2023-03-08 20:46 出处:网络
Not sure if this is the right place for MDX question but it seemed to be the most appropriat开发者_高级运维e.

Not sure if this is the right place for MDX question but it seemed to be the most appropriat开发者_高级运维e.

I have a question about MDX and the AVG function.

I would like to compute the average sale amount by day across several month for a year.

So I would like to compute the AVG of the 2010/01/01, 2010/02/01, 2010/03/01, etc... and this for everyday of the month.

Can anyone give me a hint on how I'd be able to do that ?

I would go for something that looks like this

WITH MEMBER [Measures].[Total] AS AVG(DESCENDANTS([Time].[2010], [Day]),[Measure].[Sale])

Thank you,

UPDATE

I have open a new question with a clearer explanation of my problem and study case.

Please find it at : MDX: avg advanced use


You are on the right track. You can compute the average with:

WITH
MEMBER [Measures].[Average Sales] AS
    AVG(DESCENDANTS([Time].[Calendar].CurrentMember, 
                    [Time].[Calendar].[Date]), 
        [Measure].[Sale])
SELECT
{
    [Measures].[Average Sales]
} ON 0,
{
    [Time].[Calendar].[Month]
} ON 1
FROM [YourCube]

This will give you the average for each member of the Calendar hierarchy of the Time dimension which you select. It will work for Years, Quarters, Months, etc and will average the Sale measure over days under the specified members. In your case you can just select Month on ROWS or COLUMNS as shown in the code sample.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号