Rolling Average

Hi,
I have to calculate a five week rolling average that uses wo different formulas for weeks in the past and weeks in the future with respect to the current week
. Is there a standard function for the same in SAP?
If not how do we go about doing it?
Thanks

Hi Ravi,
You can use this FM module to get current week.
Data : datum like prowf-ertag,
DATA: week LIKE scal-week.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
date = datum
IMPORTING
week = week
EXCEPTIONS
date_invalid = 1
OTHERS = 2.
write : week.
use this FM to get the previous week ..by subracting datum by 7 as there are only 7 days in week..same to fuuture weeks also...
Regards,
San!

Similar Messages

  • OBIEE 12 months rolling average

    Hi,
    I have a report requirement where i want to see 12 months rolling average for measure.
    Report filter:  Year, Period
    Ex: If i select Month and Year Sept 2013 is given as filter, it should pull data from Oct 2012 to Sept 2013 and divide it by 12.
    Please let us know the thoughts
    Thanks in advacne.

    hi,
    A general procedure hierarchy you can use.
    Create a hierarchy for time dimension, use time series function
    ago("measure",level(12 months))
    then make one logical column use this existed calculated column as sum and again make one more logical new column use the sum value column and divide it by 12.
    Just gain the solution in RPD itself.
    for more information visit here OBIEE -Time Series in OBIEE
    Regards,
    VG

  • 12 Month Moving Average and 12 months rolling average

    Hi All,
    please let me know what is difference 12 Month Moving Average and 12 months rolling average
    can i get 1 example to achieve the solution

    Hey suneel,
    Both average are more or less same, for better understanding. go through below link, where you can get some clarifications.
    http://www.brighthubpm.com/project-planning/111351-guide-to-computing-rolling-averages-for-business-forecasts/

  • 12 Months Rolling Average

    Hello,
    I am trying to calculate Rolling Average for 12 months. I followed below link and it works perfect.
    BOBJ Tricks: Moving Average in Webi
    However, my requirement is slightly different. I want to calculate even when there is not data.
    Attaching the screen shots. Is there a way possible we can do something to achieve?
    Regards

    Hi Ajoy,
    You mentioned all values of meaure/4 means you are dividing the measure value/total no of reading days?
    what is that measure?
    and you are calculationg previous(monthly av),what are you expecting from this calculation?
    suppose see the below example.
    Example
    RunningSum([Revenue]) returns these results in the following table:
    RunningSum([Revenue];([Country])) returns these results in the following table:
    In your case try to use SERVERNAME,Month/year,week(You have readings per week right?)
    try using runningsum(measure) or runningsum(previous(measure))

  • Rolling averages/sums for counts

    I am a new user (business objects 12 relaease 2)
    I would like to build a report in web intelligence displaying the average count of the number of records per day, where the average is calculated for a rolling window of days.
    For example a rolling daily average count of records using a 3 day window would be caluculated by:
    Summing the counts of records for the last three days and dividing by 3
    I would like to include this rolling average in a table for a specified of time period, say the last 30 days. My table would have two rows the top row would be the date and would hgave 30 entries, inbe for each of  the previous 30 days, The scond row would have the 3 day rolling average for each of the 30 days. This table format will also allow me to graph the table
    An additional problem arises becasue there are some dates that have no data. I need to include those dates, but Web Intelligence won't display them. Is there a way of displaying dates with no values in the table?

    John Berezowski,
    In response to your question: "An additional problem arises becasue there are some dates that have no data. I need to include those dates, but Web Intelligence won't display them. Is there a way of displaying dates with no values in the table?"
    The solution is to build a "backend table" in your data base that has all of the applicable dates accounted for.  Then modify your universe by linking this new table to your pre-existing table and process as a left outer join (providing that this new table is on the "left" side, otherwise a full outer join will suffice due to the manner that you've built your table).
    A technique you can apply to the other columns used in your original table would be the use of the "coalesce" function to avoid nulls and transform unjoined values to spaces (or zero or some other value for integers). 
    thanks,
    John

  • 30 day rolling average of a single variable based on 1 hour averages?

    Can anyone recommend the best way to keep a 30 day rolling average of a single variable based on 1 hour averages?  I am thinking about using Citadel with and SQL query to update the average.  If there's a better way, I would appreaciate any ideas.

    I think you are on the right path, use the existing Citadel information with ODBC & SQL to get the data.  
    Saves archiving "duplicate" data.
    Forshock - Consult.Develop.Solve.

  • Rolling Averages and Trans per Minute

    Is it possible to perform a rolling average calc and transaction per seconds on the BAM dashboard? I am currently building a PoC for my team and these are 2 of the requirements that I have not been able to implement using the docs. I would like to display a gauge that tells me appx how many transactions per second I am processing and a graph that displays the rolling average of my transactions over time.
    Thanks,
    Bill

    hello Bill - this may be an alternate 2nd use bar or line view- select your parameter to display a 'count' and add a filter to show it for the last 1 minute, [check activex], and after that select your grouping by the timefield, select group 1 sec, value format-as second. This should give you something close to your view.

  • Rolling Averages in Sql Server 2008

    I dint get the perfect answer last time and i am still working on the exact output that i need.
    I have the two integer columns in my table and i have to calculate averages for those two columns.Hence my output should be 
    date col1 col2 AVGcol1 AVGcol2
    and the average of each row should be avg(value of current date and sum of last five date). In this case i have more than one row for a single date.That also needs to be considered.
    Thanks in Advance!!!!!!

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I did not get the perfect answer last time and I am still working on the exact output that I need. <<
    Perhaps you might consider posting DDL and giving us sample date, so we can do your job for you?
    >> I have the two integer columns in my table and I have to calculate averages for those two columns. Hence my output should be 
    something_date, col1, col2, col1_avg, col2_avg
    and the average of each row should be avg(value of current date and sum of last five dates). In this case I have more than one row for a single date. That also needs to be considered.<<
    I might have guessed that the generic date was the key, but your narrative says this is not so. Too bad we have no idea what the key might be. Too bad we have no idea about NULLs, either! Why did we have to almost torture you to get anything? Just give us DDL
    at the start. 
    CREATE TABLE Garbage 
    (posting_date DATE NOT NULL, 
     col_1 INTEGER NOT NULL, 
     col_2 INTEGER NOT NULL, 
     PRIMARY KEY (???));
    INSERT INTO Garbage 
    VALUES
    ('2014-12-10', 250, 200), 
    ('2014-12-21', 100, 100), 
    ('2014-12-21', 150, 300), 
    ('2014-12-21', 100, 100), 
    ('2014-12-22', 150, 300), 
    ('2014-12-23', 100, 100), 
    ('2014-12-23', 150, 300), 
    ('2014-12-24', 100, 100), 
    ('2014-12-24', 150, 300), 
    ('2014-12-25', 200, 450); 
    Here is my guess: sum up each day's postings into G2. Now t34eh date could be a key! Then use G2 with a windows clause to get the prior 5 rows. That is not quite the same as the prior five
    days, however, if we have gaps. The RANGE option does not work completely in T-SQL, but we could do an outer join to a calendar table and some other tricks.
    WITH G2(posting_date, col_1, col_2)
    AS
    (SELECT posting_date, SUM(col_1), SUM(col_2) 
     FROM Garbage
    GROUP BY posting_date)
    SELECT posting_date, 
     col_1,
     AVG(col_1 * 1.00)
     OVER (ORDER BY posting_date 
     ROWS BETWEEN 5 PRECEDING AND CURRENT ROW)
     AS col1_avg, 
     col_2,
    AVG(col_2 * 1.00)
     OVER (ORDER BY posting_date 
     ROWS BETWEEN 5 PRECEDING AND CURRENT ROW)
     AS col2_avg
     FROM G2; 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Formula Variables for Key Figure Rolling Averages 3/6 months

    Dear BEx guru! I need dynamic (user selectable range from select options) 3, 6 month averages for Sales, Inventory  Key Figures. I used variable offset alone and I am not getting the results.
    Mar/06 = 120 EACH, Apr/06 = 150 EACH and May/06 = 180 EACH, Jun/06 = 90 EACH, July/06 = 240
    User Calendar Month select options = Mar/06 to May/06
    Mar/06 (Avg) = (120150180)/3 = 150 EACH
    Apr/06 (Avg) = (15018090)/3 = 140 EACH
    May/06 (Avg) = (18090240)/3 = 170 EACH
    PLEASE SEND ME YOUR KIND RESPONSES! I APPRECIATE YOUR HELP!! write to [email protected]

    Hi,
    You may have to use the customer exit.  I am not sure whether there is any sap_exit variable available to provide such a calculation.
    Regards
    Sundar

  • Rolling averages

    I would like to have a file (excel) that has  11,12,13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25 or any random numbers in no specific order.
    I would like to do an rolling calculation everytime the file reads. for example.
    Add the first 5 numbers in the file and divide by 5 then drop the first number and move one to the right and get the next 5 number  then divide by 5 etc.
    (11 + 12 + 13 + 14 + 15) / 5 = 13  the first time it reads then drop off the first number and move one to the right (12 + 13 + 14 + 15 + 16) / 5 = 14  then (13 + 14 + 15 + 16 + 17) / 5 = 15.
    Can anyone help please?
    Solved!
    Go to Solution.

    What have you tried?  Can you show you code?
    I would use a shift register to hold your 5 element array and use the Mean VI (in the Mathematics->Probability and Statistics palette) to calculate you mean.  You can then use the Replace Array Subset to put your new element in the array.  I used the Shift 1D Array with a -1 places so that the replaced element was always in the first element.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to calculate a rolling average within SQL Server Compact

    There are at least a dozen ways to skin this cat in regular SQL Server, but I am trying to solve this problem within the limitations of SQL CE. I have a table of stock values:
    Stock, Date, Open, High, Low, Close
    and I want to add 1 column "RollingAVG" which is simply the AVG(Close) over a specified timeframe (say 30 days)
    This code here works in SQL Server 2012 just fine (of course) but I need something that produces the same results in SQL CE.  Any thoughts?  Thanks!
    SELECT b.Symbol,b.DateTrade, b.ValueClose,
    (SELECT
    AVG(a.ValueClose)
    FROM
    HistoryPrice a
    WHERE
    a.DateTrade >= DATEADD(d,-30,b.DateTrade)
    AND a.DateTrade <= b.DateTrade
    AND a.Symbol = b.Symbol
    ) as Rolling30Close
    (SELECT
    MIN(a.ValueLow)
    FROM
    HistoryPrice a
    WHERE
    a.DateTrade >= DATEADD(d,-30,b.DateTrade)
    AND a.DateTrade <= b.DateTrade
    AND a.Symbol = b.Symbol
    ) as Min30Day
    (SELECT
    MAX(a.ValueHigh)
    FROM
    HistoryPrice a
    WHERE
    a.DateTrade >= DATEADD(d,-30,b.DateTrade)
    AND a.DateTrade <= b.DateTrade
    AND a.Symbol = b.Symbol
    ) as Max30Day
    FROM
    HistoryPrice b
    order by Symbol,DateTrade desc
    Shane

    Hi,
    AVG function is supported in SQL Server Compact. However, embedded select clause is not supported in Visual Studio and a SQL Execution error will be thrown out.
    I suggest you optimize your query. You can refer to the below code:
    AVG (SQL Server Compact)
    http://technet.microsoft.com/en-us/library/ms174124.aspx
    If you have any feedback on our support, please click here.
    Thanks.
    Tracy Cai
    TechNet Community Support

  • Rolling Averages - Best Practices

    Hi All,
    I have a business requirement where I need to arrive at the Overtime % for the employees for the forecast scenario which is the calculation of the immediately preceeding 12 months of Actual Data.
    I have written a long BR for each month to do what it is suppose to. I am not sure if that is the best way to do the same.
    Any suggestions. I can provide more details if interested.
    THanks in advance
    Cheers

    I assume this is a Planning app with Years and Months in separate dimensions, so you'll have to cross years.
    Any reason you wouldn't calculate this dynamically using a member formula on an account? That way, you wouldn't have to run a business rule.
    Let me know your dense/sparse settings and post your business rule and we can help more.
    - Jake

  • SSRS 2008 R2 - Add moving average to column group

    I have a column group of dollar amounts.  The row is a year/month.  I would like to add a moving average column to the right of the last 6 months.  My SQL Server data source is already complex enough and I'd really prefer not to add a column
    there.  Is there anything I can do within the report itself?  Some way to reference the previous records in a matrix?
    Thank you!

    Hi mateoc15,
    According to your description, you have a matrix in your report. Now you want to calculate the average value of last 6 month. Right?
    In Reporting Service, we can put custom code into report to deal with complicated logic. Add one more column/row inside of group and call the functions defined in custom code. For your requirement we modified Robert’s code to achieve your goal. We tested
    your case in our local environment with sample data. Here are steps and screenshots for your reference:
    Put the custom code into report:
    Private queueLength As Integer = 6
    Private queueSum As Double = 0
    Private queueFull As Boolean = False
    Private idChange As String=""
    Dim queue As New System.Collections.Generic.Queue(Of Integer)
    Public Function CumulativeQueue(ByVal currentValue As Integer,id As String) As Object
    Dim removedValue As Double = 0
    If idChange <> id then
            ClearQueue()
                    idChange = id
                    queueSum = 0
                    queueFull = False
                    CumulativeQueue(currentValue,id)
    Else
                    If queue.Count >= queueLength Then
                                    removedValue = queue.Dequeue()
                    End If
                    queueSum += currentValue
                    queueSum -= removedValue
                    queue.Enqueue(currentValue)
                    If queue.Count < queueLength Then
                    Return Nothing
                    ElseIf queue.Count = queueLength And queueFull = False Then
                    queueFull = True
                    Return queueSum / queueLength
                    Else
                    Return (queueSum) / queueLength
                    End If
    End If
    End Function
    public function ClearQueue()
    Dim i as Integer
    Dim n as Integer = Queue.Count-1
    for i=n To 0 Step-1
                    queue.Dequeue()
    next i
    End function
    Add one more row inside of group, call the function defined in custom code.
    Save and preview. It looks like below:
    Reference:
    Moving or rolling average, how to?
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou (Pactera)

  • Would anyone know how to program the Labview code for the following: Recording an analog input signal for 100msec and then repeating this 100 times in order to finally have an averaged signal (waveform)​?

    I have added a vi, but it doesn't quite work. Would be very grateful if someone could help, thanks!
    Attachments:
    Average_0411041_2.vi ‏77 KB

    The attached VI collects 100 ms of data and does a rolling average. Since your sub-VI were not included I created this from scratch. There are comments in the code. I hope this is what you need.
    Dirk
    Attachments:
    rollingaverage110x100.vi ‏47 KB

  • Problem with moving average

    I have to create a report which displays rolling average of revenue.
    The report contains two columns week and avg revenue. I have to display only ten weeks from the current week.
    For each week the revenue should be calculated as follows;
    weeks     actual revenue     Avg revenue
    1     10          10     
    2     20          (10+20)/2
    3     30          (10+20+30)/3     
    4     40          (10+20+30+40)/4
    5     50          (20+30+40+50)/4
    6     60          (30+40+50+60)/4
    (current week-10 weeks)
    current week
    I have used Mavg(actual revenue, 4) to calculate avg revenue.
    I am getting the correct values. However if I apply a filter say weeks between current week and (current week-10 weeks), I am facing a problem.
    My (current week-10 weeks) is now showing avg revenue as 10 which is my actual revenue amount.
    But i would like to show the revnue amount as an avgerage of (current week-10 weeks) and previous three weeks.
    The filter to limit the number of weeks is applied before calculating the moving average. Is there anyway to calculate the moving average first and then apply the week filter to report.
    Pls help me solving this.
    Thanks

    Do this:
    Have the measure as :
    case when Periods."Weekdate" > TIMESTAMPADD(SQL_TSI_WEEK, -10 , CURRENT_DATE) then MAVG ("Sales Measures".Units, 4) else 999999999 end
    And then apply filter on the above measure column as :
    Case when Periods.Weekdate > TIMESTAM... ' is not equal to / is not in 999999999
    Let us know how it goes.
    PS : To prevent runaway query, you may want filter it further by Periods."Weekdate" > TIMESTAMPADD(SQL_TSI_WEEK, -15 , CURRENT_DATE)

Maybe you are looking for