0
votes

Hi have to calculate sales Cost values for products in a month. Costs may vary in a month, so I have to calculate the Average Cost for a given month.

I have a column for each sale of a product with the last Cost for that product

the measure "Last Price Cost" is calculated as "Average of Children" of that column

The measure appears to be correct

Now I need to calculate the same average Cost for the previous month.

my Calculated measure is as follows:

MEMBER SalesCostMonthBefore AS (parallelPeriod([Dim Time].[Year - Month - Date].[Month],1 ), [Measures].[SalesLastPriceCostUnitary])

but this doesn't get the correct result...(tried on a product which always had the same Cost and it swohws 4.72€ for this month (correct) but 5.66 for previous month (not correct)

1

1 Answers

0
votes

Do you has specified the Time CurrentMember?

The function ParallelPeriod works with the [Dim Time] CurrentMember parameter.

In the next query Example, the Time CurrentMember is [Dim Time].[Year - Month - Date].&[2012].&[02]:

WITH
MEMBER SalesCostMonthBefore AS (parallelPeriod([Dim Time].[Year - Month - Date].[Month],1 ), [Measures].[SalesLastPriceCostUnitary])
Select
{SalesCostMonthBefore} On 0, 
{Products.Category.Members} ON 1
From CUbeName
WHERE  ([Dim Time].[Year - Month - Date].&[2012].&[02])