If you are unable to create a new account, please email support@bspsoftware.com

 

find average of calculated fields/apply case statement in measure dimension

Started by kiran.timsina, 07 May 2013 04:12:03 PM

Previous topic - Next topic

kiran.timsina

I have a calculated field `a/b` which makes sense at week level, where `a` is last of period metric and `b` is sum of the period metric. I need to find `avg(a/b)` for the weeks that fall under a month and not `end_of_month(a)/sum(b) for the month`. I made my `a/b` metric with regular aggregate as calculated and then monthly average metric with regular aggregate as average, but it doesn't work.

`a` is end on hand inventory, `b` is sales, `a/b` is weeks of supply. Both `a` and `b` spread along product/location/time dimensions. For `a`, I've set its regular aggregate for time as last to get the end on hand inventory for a week.

Approaches taken:
1. made a query item by pulling weeks of supply metric for week level and changed its regular aggregate to average. It doesn't work either.
2. `average((total([a] for [week]))/(total( for [week])))` which is error-free but doesn't give correct result. I used total[a] because it still has to sum along other dimensions except time.
3. made individual weeks of supply metrics and then derive a new metric as (first week wos + ...+fifth week wos)/5. But here I have problem in applying case statement which says "Relational query objects are being used in conjunction with Dimensionally-modeled relational objects". I applied a case statement to test whether its a first week or second week and so on and ended up getting incorrect values.

I think I can solve the problem if I can apply case statement while defining a calculated measure inside a measure dimension by going for Approach 3. This should be easy but I get incorrect result. Any ideas? Thanks.