Oracle Analytics Cloud and Server

Welcome to the Oracle Analytics Community: Please complete your User Profile and upload your Profile Picture

OACS : Moving Average

Received Response
251
Views
6
Comments

Summary:

Hello,

We are trying to calculate 5 day Moving average for Sales data. Sample data and expected result as below.

We are using MAVG function of OACS. However we cannot pass group by Product to this function which is skewing the results of Product P2 and P3.

Example : Without the group by clause, Product P2 is picking up rows from P1 in calculating the MAVG and this results in incorrect results.

Any suggestions will be of great help.



Content (required):


Version (include the version you are using, if applicable):


Code Snippet (add any code snippets that support your topic, if applicable):

Tagged:

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • Rank 5 - Community Champion

    The method below is only feasible with a small amount of Products.

    You could create a separate analysis for each product grouping and in the measure parameter you can filter to specific products:

    MAVG(FILTER(SALES USING PRODUCT = 'P1'), 5)
    

    Otherwise, you can use the EVALUATE_AGGR function which allows Aggregate Functions with GROUP BY

  • Rank 7 - Analytics Coach

    I guess, you can use in MAVG syntax (as for any aggregation function) BY <<column>> clause, where you specify resetting column for MAVG function - thus aggregation will be reset when value of <<column>> changes. So in your case it should look like: MAVG(SALES ,5 BY PRODUCT). "Disadvantage" is, that you need to specify custom calculation for each combination you will need.

  • Rank 6 - Analytics Lead

    Hi Bharath ,

    Please put product column name in group by under Advanced Tab option and apply then it will work.

    Please check once.




  • Rank 4 - Community Specialist

    @ALOK SH-Oracle - Thanks for this solution, Yes it works fine in OACS classic. Is there anyway we can do this in DV workbook ?

  • Rank 4 - Community Specialist

    Thanks @Joshua C. Stewart for your help. I ended up using EVALUATE_AGGR functions as we have over 100k products.

  • Rank 7 - Analytics Coach

    @Bharath Raghupathi-Oracle Have you tried approach, i was reccomending to you ? Using custom calculation in DV: MAVG(SALES ,5 BY PRODUCT) ? This should definitelly work….

Welcome!

It looks like you're new here. Sign in or register to get started.