Average for last 7 days

I am trying to calculate Deviation Measure for the Reports and the formula to calculate is –
(average(last 7 days count ) – today’s count/100 )*10
Problem here is to calculate average for last 7 days .
I am using moving average but if I apply a filter , Moving average is calculated for the number of rows displayed whereas I want it for the number of days.
Formula for Moving average is - MAVG(Row Count,n) where n is number of rows displayed and not number of days. Is there any possible way to do it.

(average(last 7 days count ) – today’s count/100 )*10
Filter( avg(col1) using date > current_date-7)) --Average for last 7 days
Filter(count(col) using date = current_date) - today's value

Similar Messages

  • Calculate NWC (Average for last 4 Month)

    Do someone know how to calculate NWC (Average for last 4 Month) using @AVG?FIX ("2002", Jan)     "Net Working Capital (Average for last 4 Month)" = @AVG(SKIPMISSING, "Net Working Capital", "2001"->Oct,"2001"->Nov, "2001"->Dec, "2002"->Jan);ENDFIXIn my case, we split the Year and Month Dim in our outline.Can this script work in under our situation???Thanks

    Try usingFIX ("2002", Jan) "Net Working Capital (Average for last 4 Month)" = @AVG(SKIPMISSING, "Net Working Capital"->"2001"->Oct,"Net Working Capital"->"2001"->Nov,"Net Working Capital"->"2001"->Dec,"Net Working Capital"->"2002"->Jan); ENDFIX

  • UDF for last day of week/month

    Input is a Date(For example: 2010/03/12) in String  format.
    I need to extract the last day of that week and return it as a string output.
    For example if input is 2010/03/12 and thatu2019s a Thursday my output should be 2010/03/14 i.e Saturdayu2019s date.
    Similarly I need to extract last day of month too.
    Thanks in advance
    Soumen...

    Hi,
    I did not develop this one... but just use "search" button on roseindia and you will have the answer (I think):
    [http://www.roseindia.net/java/beginners/DayOfYearToDayOfWeek.shtml|http://www.roseindia.net/java/beginners/DayOfYearToDayOfWeek.shtml]
    and do not forget that Google is your friend...
    do a research with : Java last day of week, and you have plenty of examples.
    Thanks.
    P.S: Say us when you will solved your problem.

  • Variable for last day of last month....

    Hi,
    Can somebody let me know the code to find the last day of last month from the query variable.
    Is there any standard/business content  variable available for this?
    I have found one similar variable , but its for the posting date.
    Any help is appreciated.
    Regards...

    Check this code:
    l_date_from = sy-datum.
           l_date_from+6(2) = '01'.
           l_date_from = l_date_from - 1.
           l_s_range-sign = 'I'.
           l_s_range-opt  = 'EQ'.
           l_s_range-low = l_date_from.
           l_s_range-high = space.
           APPEND l_s_range TO e_t_range.
    You can modify based on your specific requirement.
    Regards,
    Kams

  • Dynamic Variable for last day of month

    Hi all,
    I have created one report where in YTD is calculated based on stsyem date. NOw in this report the cal month is in row thus displaying data month wise. But i need one key figure which giving the last day vaue of every month that are displayed in YTD i.e this is based on cal day. Thus the report layout is as follows:
    if report is run in mar 2007 then it should display:
    calmonth            key figure due amount
    Jan 07                this should show due value on last day of jan 07 (i.e 31st jan 07)
    Feb 07               this should show due value on last day of feb 07 (i.e 28th feb 07)
    Mar 07               this should show due value on last day of mar 07(i.e 31st mar 07)
    customer exit variable can give me only one value at a time. How can I make it dynamic to take last day value of every month as per cal month. Could anybody explain me if worked on any such issue.
    If there is some how to paper kindly mail me at my email Id : [email protected]
    thanks in advance
    Regards,
    Wrushali

    Hi,
    We can assign multiple single values to the customer exit.
    So in the Query take CALMONTH in rows.
    And take your KF in column with Customer exit variable restriction on CALDAY.
    So in the code of this Cusotmer exit varible, from the Current date find out the year of the current date and then assign those 12 required days to this variable.
    With rgds,
    Anil Kumar Sharma .P

  • Average for last 12 months

    hi,
    i have a column amount. i need to find the avg of it for last 12 months excluding current month.
    I have got a query to find it .but it is adding current month also with it.
    AVG(SUM(amount)) OVER (ORDER BY ACCOUNT_MONTH_NO
    ROWS BETWEEN 12 PRECEDING AND 0 FOLLOWING) rolling_avg,
    please help me to write a query as i am a naive user of oracle.

    Like..
    SQL> select * from test;
    ACCOUNT_NU ACCOUNT_MONTH_NO     AMOUNT
    ACC1                      1        100
    ACC1                      2        200
    ACC1                      3        300
    ACC1                      4        400
    ACC1                      5        500
    ACC1                      6        600
    ACC1                      7        700
    ACC1                      8        800
    ACC1                      9        900
    ACC1                     10       1000
    ACC1                     11       1100
    ACC1                     12       1200
    12 rows selected.
    SQL> select account_month_no,amount,
      2     avg(amount) over(order by account_month_no rows
      3            between 12 preceding and 1 preceding) avg
      4  from test
      5  where ACCOUNT_NUMBER  = 'ACC1';
    ACCOUNT_MONTH_NO     AMOUNT        AVG
                   1        100
                   2        200        100
                   3        300        150
                   4        400        200
                   5        500        250
                   6        600        300
                   7        700        350
                   8        800        400
                   9        900        450
                  10       1000        500
                  11       1100        550
                  12       1200        600
    12 rows selected.Post sample data and expected output, so that we can help you better

  • Select statement for last day of the last quarter and first quarter

    Anybody provide me the single select statement which should result the last day of the last quarter and last day of current quarter?
    Ex: Select last date of the last quarter,last day of current quarter from XYZ(DUAL...)
    Thanks in Advance

    Hi,
    Here's one way:
    SELECT               TRUNC (SYSDATE, 'Q') - 1     AS prev_qtr_end
    ,     ADD_MONTHS ( TRUNC (SYSDATE, 'Q') - 1
                 , 3       
                 )                    AS this_qtr_end
    FROM    dual;TRUNC (dt, 'Q') returns the first day of the quarter containing dt.
    Subtract one day from that, and you have the last day of the previous quarter.
    Add 3 months to that, and you have the last day of the current quarter. ADD_MONTHS (dt, n) will always return the last day of a month if its first argument, dt, is the last day of a month.

  • Printing Last Day of previous month

    I need to print Last day of previous month, and the date value is relative to the system date.
    In my previous post i have got the answer to print last day of current month. To print last date in previous month do i need to use RelativeDate? and I am not sure whether I can use RelativeDate for months.
    Raghu

    Right now I have written below formula, and it works fine in all cases like if the current month equals to 01, 03, 05,07,08,10 and 12 and months other than mentioned in above including 02.
    for First day of previous month
    =If (FormatDate(CurrentDate();"MM"))InList("07";"08";"10";"12";"05";"01";"03") Then
    (If(FormatDate(CurrentDate();"dd"))="01" Then
    FormatDate(LastDayOfMonth(RelativeDate(CurrentDate();-1));"MM")"/01/"FormatNumber(Year(LastDayOfMonth(RelativeDate(CurrentDate();-1)));"####")Else
    FormatDate(LastDayOfMonth(RelativeDate(CurrentDate();-31));"MM")"/01/"FormatNumber(Year(LastDayOfMonth(RelativeDate(CurrentDate();-31)));"####"))Else
    FormatDate(LastDayOfMonth(RelativeDate(CurrentDate();-30));"MM")"/01/"FormatNumber(Year(LastDayOfMonth(RelativeDate(CurrentDate();-30)));"####")
    For Last day of previous month
    =If (FormatDate(CurrentDate();"MM"))InList("07";"08";"10";"12";"05";"03";"01") Then
    (If(FormatDate(CurrentDate();"dd"))="01" Then LastDayOfMonth(RelativeDate(CurrentDate();-1))Else
    LastDayOfMonth(RelativeDate(CurrentDate();-31)))Else LastDayOfMonth(RelativeDate(CurrentDate();-30))
    Please let me know any other suggestions.
    -Raghu

  • SQL help: return number of records for each day of last month.

    Hi: I have records in the database with a field in the table which contains the Unix epoch time for each record. Letz say the Table name is ED and the field utime contains the Unix epoch time.
    Is there a way to get a count of number of records for each day of the last one month? Essentially I want a query which returns a list of count (number of records for each day) with the utime field containing the Unix epoch time. If a particular day does not have any records I want the query to return 0 for that day. I have no clue where to start. Would I need another table which has the list of days?
    Thanks
    Ray

    Peter: thanks. That helps but not completely.
    When I run the query to include only records for July using a statement such as following
    ============
    SELECT /*+ FIRST_ROWS */ COUNT(ED.UTIMESTAMP), TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD') AS DATA
    FROM EVENT_DATA ED
    WHERE AGENT_ID = 160
    AND (TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY')+(ED.UTIMESTAMP/86400)), 'MM/YYYY') = TO_CHAR(SYSDATE-15, 'MM/YYYY'))
    GROUP BY TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD')
    ORDER BY TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD');
    =============
    I get the following
    COUNT(ED.UTIMESTAMP) DATA
    1 07/20
    1 07/21
    1 07/24
    2 07/25
    2 07/27
    2 07/28
    2 07/29
    1 07/30
    2 07/31
    Some dates donot have any records and so no output. Is there a way to show the missing dates with a COUNT value = 0?
    Thanks
    Ray

  • How do I set a reminder for the last day of every month

    Have I missed something? But how do you set a reminder for the last day of every month to recurr indefinatley in iOS6? Sorry if this is really simple but I just can't seem to work it out. Any help gratefully received.

    Hey Mattye88 not sure if you have seen but actully you can do this, but for some reason you have to use Siri.  If you bring up Siri and say "set a reminder ever 4 weeks from next wednesday to check the gas meter" it will set one and it will work just fine, I have reminders to water a Bonsai every three days and it works fine it just shows as custom repeat on the user interface.  Alas it seems you can not use Siri to set one for the end of the month though which is why I am in this threed.  Still hope it helps you to know how to sort this problem atleast.

  • Last day of previous month for data load

    Hi,
    I have to load data from the previous month into the psa and then into an infocube. I was wondering as to how to get the last of the previous month to write a code in ABAP. I will be writing the code at the infopackage level in the data selection. I could load data from the 1st of the previous month to the 1st of the current month. This will be an additional load of 30,000 records for the 1st of every month, since I will be loading 30,000 records everyday, I was wondering if I could limit the load from the 1st of every previous month to the last day of that month. This will be a repetitive loading.
    DATA: CURR_MM(2) TYPE N,
    CURR_YYYY(4) TYPE N,
    CURR_DD(2) TYPE N,
    PREV_MM(2) TYPE N,
    PREV_YYYY(4) TYPE N,
    PREV_DD(2) TYPE N,
    YYYY_MM(6),
    YYYY_MM1(6),
    DATE LIKE SY-DATUM.
    DATE = SY-DATUM.
    CURR_YYYY = DATE+0(4).
    CURR_MM = DATE+4(2).
    CURR_DD = DATE+6(2).
    PREV_DD = 1.
    IF CURR_MM = '01'.
    PREV_MM = '12'.
    PREV_YYYY = CURR_YYYY - 1.
    ELSE.
    PREV_MM = CURR_MM - 1.
    PREV_YYYY = CURR_YYYY.
    ENDIF.
    concatenate PREV_YYYY PREV_MM PREV_DD into YYYY_MM.
    concatenate CURR_YYYY PREV_MM PREV_DD into YYYY_MM1.
    read table l_t_range with key
    fieldname = 'BLDAT'.
    l_idx = sy-tabix.
    l_t_range-low = YYYY_MM.
    l_t_range-high = YYYY_MM1.
    l_t_range-sign = 'I'.
    l_t_range-option = 'BT'.
    modify l_t_range index l_idx.
    p_subrc = 0.
    Mind you this code will load data from 1st of the previous month to the 1st of current month. I just don't want to load that extra "1st day" of current month data as I have 30,000 records everyday.
    Say for example, I want to load data from 1st Mar to 31st Mar or 1st Feb to 28thFeb. How should I modify the above code.
    Is there a formula to get the last date of the previous month. That's all I need. This would solve the problem.

    try this routine. it will return a range from 1st day to end of the month.
    DATA: l_s_range TYPE rsr_s_rangesid,
              E_T_RANGE TYPE  RSR_T_RANGESID.
    DATA: year(4) TYPE n,
          month(2) TYPE n,
          day(2) TYPE n,
        ld_keydate  TYPE sydatum,
          ld_lastday  TYPE sydatum.
      REFRESH e_t_range.
      CLEAR l_s_range.
      year  = sy-datum(4).
      month = sy-datum+4(2).
    *Months with 31 days in year
      IF month = '01' OR
         month = '03' OR
         month = '05' OR
         month = '07' OR
         month = '08' OR
         month = '10' OR
         month ='12'.
        day = '31'.
      ENDIF.
    *check for leap year: provoking sy-sybrc <> 0
      IF month = '02'.
        day = '29'.
        MOVE:   '02'        TO ld_keydate+4(2),
                year        TO ld_keydate(4),
                day         TO ld_keydate+6(2).
        CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
          EXPORTING
            date   = ld_keydate
          EXCEPTIONS
            OTHERS = 1.
        IF sy-subrc <> 0.
          day = '28'.
        ENDIF.
      ENDIF.
    *months with 31 days in year
      IF month = '04' OR
         month = '06' OR
         month = '09' OR
         month = '11'.
        day = '30'.
      ENDIF.
      MOVE: year              TO ld_lastday(4),
            month             TO ld_lastday+4(2),
            day               TO ld_lastday+6(2).
      l_s_range-low  = sy-datum.
      l_s_range-high = ld_lastday.
      l_s_range-sign = 'I'.
      l_s_range-opt  = 'BT'.
      APPEND l_s_range TO e_t_range.

  • How to get Maximum Number of Concurrent users for last few days?

    Hi,
    How I can get maximum number of concurrent users which were logged in to the system (ECC 5.0) I mean I want to check the hostory for last few weeks. Is there any way to get the same? I know that I can get Cumulative number of users in st03 under Expert mode but that is the number of users logged into the system during the day. Is there any place where SAP maintians the High Watermark of Number of concurrent users reached in the system?
    Thanks in advance...
    Regards,
    Pravin

    Sorry I really missed that I have posted a question here on sdn. I wanted to know this for planning the system hardware requirements. Activities like PM ( Performance Management ) happens once a year and during that activity we see heavy user loan on the system so if I have the exact stats of 1 or 2 years data I can size the system better next time. Fortunately last 2 years PM was very smooth for us. In that look for the improvement because each time we had little extra Harware. By doing the exact analysis we can save a Cost of ownership...
    I was looking for R/3 users. I could see the number in st07 but I want to know the exact number at particular time.. I believe that st07 stores only for few days.
    Thanks
    Pravin

  • Query for back 2nd motnh first day and last day

    Any body please provide me the query for back 2nd month first day to back 2nd month last day?
    last month first day
    TIMESTAMPADD(SQL_TSI_MONTH,-1, TIMESTAMPADD(SQL_TSI_DAY, -(DAY(CURRENT_DATE)-1), CURRENT_DATE))
    last month last day
    TIMESTAMPADD(SQL_TSI_DAY, -(DAY(CURRENT_DATE)), CURRENT_DATE)
    anyone please provide me the queries for previous months like above queries?
    2nd back month first day --?
    2nd back month last day--?
    3rd back month first day --?
    3rd back month last day --?

    Hi,
    Check with this...
    Previous month last day -
    TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE)
    Last day of 2nd month -
    TIMESTAMPADD(SQL_TSI_MONTH,-1,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))
    Last day of 3rd month -
    TIMESTAMPADD(SQL_TSI_MONTH,-2,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))
    (OR)
    Previous month last day -
    TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE)
    Last day of 2nd month -
    TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))*-1,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))
    Last day of 3rd month -
    TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))*-1,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE)))*-1,TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))*-1,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE)))
    Regards,
    Srikanth

  • For the previous month first day and last day

    i want to schedule my reports from the last month first date to last month last date.
    any body have queries for the while scheduling to uuse it.
    Ex:sysdate() - today's date
    first_day_of_month()- first day of current month
    first day of last month ---?
    last day of the last month ---?

    In the parameter, put this
    {$FIRST_DAY_OF_MONTH()$}other values you can use in default parameter values are
    {$SYSDATE()$} - to get current date
    {$FIRST_DAY_OF_MONTH()$} - to get first day of the current month
    {$FIRST_DAY_OF_YEAR()$} - to get first day of the current year
    {$LAST_DAY_OF_MONTH()$} - to get last day of the current month
    {$LAST_DAY_OF_YEAR()$} - to get last day of the current year
    Re: Default date as first of month
    TO get last day of last month
    {$FIRST_DAY_OF_MONTH()-1$}You can add/subtract number with these functions and no other functions are available.

  • I use BB Bold 9790 and my battery which could at least,last for a day now at most,lasts for an hour

    I use BB Bold 9790 and my battery which could at least,last for a day now at most,lasts for an hour and half.
    The phone heats up so much that I am always forced to plug out the battery always.
    Please help cos I love the device!
    An more so can't afford to buy a new one cos its a little pricey.

    Oh, then reread Post 2 please, for the last paragraph gives you options to proceed with. Not knowing which you desire to use, I'll just give you a bunch and you can choose.
    The simplest way is to, on a PC (you cannot do this on MAC):
    1) Make sure you have a current and complete backup of your BB...you can find complete instructions via the link in my auto-sig below.
    2) Uninstall, from your PC, any BB OS packages
    3) Make sure you have the BB Desktop Software already installed
    http://us.blackberry.com/software/desktop.html
    4) Download and install, to your PC, the BB OS package you desire:
    http://us.blackberry.com/support/downloads/download_sites.jsp
    It is sorted first by carrier -- so if all you want are the OS levels your carrier supports, your search will be quick. However, some carriers are much slower than others to release updates. To truly seek out the most up-to-date OS package for your BB, you must dig through and find all carriers that support your specific model BB, and then compare the OS levels that they support.
    5) Delete, on your PC, all copies of VENDOR.XML...there will be at least one, and perhaps 2, and they will be located in or similarly to (it changes based on your Windows version) these folders:
    C:\Program Files (x86)\Common Files\Research In Motion\AppLoader
    C:\Users\(your Windows UserName)\AppData\Roaming\Research In Motion\BlackBerry\Loader XML
    6a) For changing your installed BB OS level (upgrade or downgrade), you can launch the Desktop Software and connect your BB...the software should offer you the OS package you installed to your PC.
    6b) Or, for reloading your currently installed BB OS level as well as for changing it, bypass the Desktop Software and use LOADER.EXE directly, by proceeding to step 2 in this process:
    http://supportforums.blackberry.com/t5/BlackBerry-Device-Software/How-To-Reload-Your-Operating-Syste...
    Note that while written for "reload" and the Storm, it can be used to upgrade, downgrade, or reload any BB device model -- it all depends on the OS package you download and install to your PC.
    If, during the processes of 6a or 6b, your BB presents a "507" error, simply unplug the USB cord from the BB and re-insert it...don't do anything else...this should allow the install to continue.
    You may also want to investigate the use of BBSAK (bbsak.org) to perform the wipe it is capable of.
    You may also want to try the "Bare Bones OS Reload Procedure" to attempt to narrow down the precise causal item:
    Load your OS "bare bones"...if anything is optional, do not install it.
    If the behavior presents immediately, then try a different OS with step 1
    If the behavior does not immediately present, then run for as long as it takes for you to be sure that the behavior will not present.
    Add one thing -- no matter how tempting, just one.
    If the behavior does not present immediately, then again run for long enough to be sure it will not have the same problem
    Repeat steps 4 and 5 until all things are loaded or the behavior presents
    When the behavior presents, you know the culprit...the last thing you loaded.
    If the behavior does not re-present, then you know that either step 1 or 2 cured it.
    If the behavior presents no matter what, then you likely have a hardware level issue for which no amount of OS or software can cure.
    You may also need the use of these tricks:
    KB10144 How to force the detection of the BlackBerry smartphone using Application Loader
    KB27956 How to recover a BlackBerry smartphone from any state
    http://crackberry.com/blackberry-101-lecture-12-how-reload-operating-system-nuked-blackberry
    If you are on MAC, you are limited to only your carriers sanctioned OS packages...but can still use any levels that they currently sanction. See this procedure:
    KB19915How to perform a clean reload of BlackBerry smartphone application software using BlackBerry Desktop Software
    Good luck and let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

Maybe you are looking for