views:

29

answers:

0

I have database where i have all sales data. And I need to calculate average sales qty for previous 3 months for current year

Let's consider that we are browsing the cube1:

select AdjSalesQty1, SalesQty on rows

& Calendar months on columns

condition is get the average for current year and where dimension for previous 3 months is set to true?

For this 2 condition we filter the two dimensions; currentyear and previous3month in cube browser

but the result you get is not correct 'coz calculation does not include the months required to get the average for sales qty.

and when you use MDX queries mdx query with filter gives you the correct answer but msx query with where clause does not

what is the solution for this?

correct mdx

WITH MEMBER [Measures].[AdjSalesQty1] AS AVG([Period].[Month].CurrentMember.Lag(3):[Period].[Month].CurrentMember,[Measures].[SalesQty]),FORMAT_STRING = "#,##0;-#,##0",VISIBLE = 1
SELECT {[Measures].[AdjSalesQty1], [Measures].[SalesQty]} ON ROWS,
FILTER([Calendar].[Month].CHILDREN, [Calendar].[Prev3Months].&[TRUE]) ON COLUMNS
FROM CUBE1

incorrect mdx

WITH MEMBER [Measures].[AdjSalesQty1] AS AVG([Period].[Month].CurrentMember.Lag(3):[Period].[Month].CurrentMember,[Measures].[SalesQty]),FORMAT_STRING = "#,##0;-#,##0",VISIBLE = 1
SELECT {[Measures].[AdjSalesQty1], [Measures].[SalesQty]} ON ROWS,
[Period].[Month].CHILDREN ON COLUMNS
FROM CUBE1
WHERE ([Period].[CurrentYear].&[TRUE], [Period].[Prev3Months].&[True])