Reset running sum

Hello,
I need to calculate running sum for each row. I' ve created pivot table report where both dimensions are dates. When I use function RSUM, it sums all values from first record till current record (totals for all rows), but I need a running sum for each row.
Is there any way to get running sum for specific group (dimension value change) record similar as it could be in Oracle SQL using OVER(PARTION BY) construct?
For example, if there is a table with 3 rows and 2 columns:
_*1*      *2*
*1* 2 4
*2* 1 3
*3* 1 2
Then corresponding table with running sums will be:
_*1*      *2*
*1* 2 6
*2* 1 4
*3* 1 3
Thanks

use the aggregate by statement:
http://obiee101.blogspot.com/search?q=aggregate
regards
John
http://obiee101.blogspot.com

Similar Messages

  • "Display As Running Sum" Feature

    Hi
    Tried to use "Display As Running Sum" feature and it looks like it adds all the values across the pivot table and does not reset it on a new row...
    So for instance we ahve a table as follows
    A 1 2
    A1 3 4
    A2 5 6
    After running sum applied:
    A 1 3
    A1 6 10
    A2 15 21
    Is there any way value could be reset after each row ? Any hidden configuration file to be changed ?

    Initial data is:
    Product Date Value
    A Day1 1
    A Day2 2
    A Day3 3
    A1 Day1 4
    A1 Day2 5
    A1 Day3 6
    A2 Day1 7
    A2 Day2 8
    A2 Day3 9
    Pivot table looks like:
    ---- Day001 Day002 Day003
    A 1 2 3
    A1 4 5 6
    A2 7 8 9
    Required table (values disaplyed as running sums by product)
    ---- Day001 Day002 Day003
    A 1 3 6
    A1 4 9 15
    A2 7 15 24
    PROBLEM: its easy to create formula RSUM(value by product) and put it as pivot table measure BUT I have around 1000 reports with different dimensions which requires to create RSUM(value by dimension1), RSUM(value by dimension2) ... RSUM(value by dimension1000) and its sort of nightmare...
    Instead of RSUM I thought that feature "Display As Running Sum" could be used, but its not working as expected in terms of it does not get reset for each row. How do I configure "Display As Running Sum" to reset value for each row ?
    PS: this is what "Display As Running Sum" gives
    ---- Day001 Day002 Day003
    A 1 3 6
    A1 10 15 21
    A2 28 36 45

  • RSUM : how to reset the sum ?

    Hello,
    I created a colum, based on the following formula : RSUM(sales), that I want to compare to another colums : RSUM(Target).
    Then, I want to compare the values and their evolutions month by month. Therefore, I display the following data :
    - Company
    - Salesman
    - RSUM(Sales)
    - RSUM(Target)
    For the first salesman, it works. But then, the sum doesn't reset, and the next salesman starts with a wrong number.
    I haven't found any solutions to force the reset of the RSUM salesman by salesman. I saw an option in pivot table (Show as running Sum). It works for the number, but not for the graph !
    Is there a solution for this problem ?
    Thanks

    hello
    I also have an issue with this running sum. The only difference is that inside the report we use a column selector.
    So defining the column fixed with the rsum (x by y) is not possible (as far as I know).
    Does that mean that I have to define the measure in the RPD as RSUM over all lowest levels of the different dimensions and that OBI will generate the correct query if I select only 2 or 3 of the 12 dimensions?
    Or are there any other methods to handle this?
    Koen Verheyen

  • Running Sum does not reste at the start of new period

    Hi Gurus,
    I am using function Running SUm for a variable. The problem is our Fiscal period starts in September. SO the running sum should reset at teh start of every period. but its not happening.
    Any Idea why?
    Regards

    Hi,
    As I see it
    num RunningSum(measure[;Row|Col][;reset_dims])
    You are using to many variables for reset_dims, if you wanna do it this way, create a variable and add this v_FY_Sort_1;Output;Site to that variable then use
    RunningSum(COGM RM Cost Total Amt Actual; variable)

  • Running Sum on Two Dimension object

    Dear All,
    I have below scenario:
    In Crosstab:
    Row: Region,State
    Column : Month
    Measure - Sales & Sales % (= Sales for State/Total Sales for that Region)
    Expected Output:
    Region - Month   ---   Jan Sales -Jan % -  Feb -   Feb % -   Mar - Mar %
    West - State -1  -- 10   -    66%(10/30) -   40 - 66% (40/60) -   50 - 50%(50/100)
    West  -State -2  --  20   -   34% (20/20) -   20 - 34% (20/60)  -  50- 50% (50/100)
    West Running Total   30 - 100%    -  60 -100% -  100 -100%
    East - State -1  -- 0   -    0%(0/0) -   60 - 100% (60/60) -   50 - 50%(50/100)
    East  -State -2  --  20   -  100% (20/20) -   0 - 0% (0/60)  -  50- 50% (50/100)
    West Running Total   20 - 100%    -  60 -100% -  100 -100%
    Actual Output:
    Month   ---   Jan Sales -Jan % -  Feb -   Feb % -   Mar - Mar %
    West - State -1   10   -    66%(10/30) -   40 - 57% (40/70) -   50 - 35%(50/140)
    West - State -2    20   -   34% (20/20) -   20 - 22% (20/90)  -  50- 26% (50/190)
    Running Total   30 - 100%    -  90 (304030)  -79% -  100 -61%
    East - State -1  -- 0   -    0%(0/0) -   60 - 75% (60/80) -   50 - 35%(50/140)
    East  -State -2  --  20   -  100% (20/20) -   0 - 0% (0/80)  -  50- 27% (50/180)
    West Running Total   20 - 100%    -  80 -75% -  180 -57%
    My Running Total Formula is : = Runningsum( Sales; (Region))
    Sales % =  Sales / Running Total Formula
    In short, I want to reset running total while my state and Month gets change. Here what's going on is while my state will get change, sum will reset and if I use Month in Running Sum formula I will get reverse effect in State.
    Can anyone have idea how to solve this issue ?
    Any answer would be appreciate.
    Regards,
    Rishit

    hi Rishit,
    You need not create any formulas to achieve the expected output.
    Create a cross tab with
    row -> region, state
    column -> month
    measure -> sales
    Apply a break on Region
    Now select sales column 
    1) insert sum using Summary(Sigma) button.
    2) insert Percentage using Summary button
    3) Remove unrequired row i.e. horizontal rows for Percentage. But keep the Percentage Column
    4) Manually you can type 100% on right hand side of sum.
    Regards,
    Vamsee

  • Logical Columns - Running Sum & 3Month Rollover

    Hi All,
    Need to build a logical column.
    I have a column with number of units (count distinct) in RPD.
    I need to build a new logical column in the REPOSITORY , such that it has running sum values.... sothat when i pick this #units column and months column in the ANSWERS...I need to get roll over of all previous values for first month.
    Say Jan ---> XXXX units ( summation of all previous available units - few years)
    Feb----> YYYY units ( sum of till jan values & Feb units)
    Mar----> ZZZZ ...etc ( sum of till Feb values & Mar units) so on.
    Based on this newly built column I need to build another column of " 3 months roll over " column.
    Replies appreciated.
    Thanks in advance.

    Hi user11939829m
    So help me understand your new measures a little better. For the sake of this post, let's say your data is like so
    Month Year -- Units
    Jan 2010 -- 1
    Feb 2010 -- 2
    Mar 2010 -- 3
    Apr 2010 -- 4
    May 2010 -- 5
    Jun 2010 -- 6Then let's say you have a report with the above columns and the new running sum columns.
    Month Year -- Units -- Running Sum Units
    Jan 2010 -- 1 -- 1
    Feb 2010 -- 2 -- 3
    Mar 2010 -- 3 -- 6
    Apr 2010 -- 4 -- 10
    May 2010 -- 5 -- 15
    Jun 2010 -- 6 -- 21Now what exactly would your three months rollover be? Would the 3 month rolling sum = running sum for current month + running sum for last month + running sum for last last month?
    i.e.
    Month Year -- Units -- Running Sum Units -- 3 Month Rolling Sum
    Jan 2010 -- 1 -- 1 -- 1
    Feb 2010 -- 2 -- 3 -- 4
    Mar 2010 -- 3 -- 6 -- 10
    Apr 2010 -- 4 -- 10 -- 19
    May 2010 -- 5 -- 15 -- 31
    Jun 2010 -- 6 -- 21 -- 46Not sure what value such a measure would add. Or do you mean 3 month rolling sum would be the running sum for just the last three months (like below)? This makes more sense but in your description, you indicated that you'd build the 3 month rolling sum off of the running sum which confused me a bit.
    Month Year -- Units -- Running Sum Units -- 3 Month Rolling Sum
    Jan 2010 -- 1 -- 1 -- 1
    Feb 2010 -- 2 -- 3 -- 3
    Mar 2010 -- 3 -- 6 -- 6
    Apr 2010 -- 4 -- 10 -- 9
    May 2010 -- 5 -- 15 -- 12
    Jun 2010 -- 6 -- 21 -- 15 Is that what you are going for? Please elaborate.
    Best regards,
    -Joe

  • Running Sum in Pivot Table

    Hi Experts,
    I have the following pivot table:
    ----------SUM1--SUM2--SUM3
    -------A--20------30-------45
    -------P--10------15--------5
    ----DIFF-10------15-------40
    where the last row is new calculated item. Is it possible to create another calculated row by using value from the 'Diff' row?. What I want to achieve is Running Sum for 'Diff' row.
    So I need an output like:
    ----------SUM1--SUM2--SUM3
    -------A--20------30-------45
    -------P--10------15--------5
    ----DIFF-10------15-------40
    RSUM-10----25-------65
    My BI version is BI EE 10.1.3.4.1. I suppose that some kind of trick will be helped.
    Thanks in advance for any suggestion
    Regards,
    Esk

    Hi, It is possible in pivot view.
    You need to move the measure labels to the left..where it says rows.
    Once that is done, we can click on any of the facts and choose display as running sum

  • Running sum per column in pivot table

    Hello,
    I am facing a problem with a running sum in a pivot table. As you know, the running sum provided by OBIEE spans across rows and columns. My requirements force me to have a running sum per each column (I have four columns, one for each quarter of the year). My pivot is as follows:
    ------------------------------|| 1st Quarter / 2nd Quarter ...
    type of product / status || (Measure / Running Sum) / (Measure / Running Sum) ...
    I've tried using the evaluate function with a "sum over" but that doesn't seem to work either.
    Do you have any ideas that could be useful to solve this?
    Thank you in advance for your time,
    João Marques

    Do not use the "running measure" button in pivot table, but try this :
    edit the formula of your measure and type :
    RSUM(mesure by dimension)
    where dimension is the attribute dimension that you put on the ROWS of your pivot table
    Exemple : I've got the criteria REVENUE, YEAR, CUSTOMER TYPE
    I put the YEAR in the Columns of the pivot table
    I put the CUSTOMER TYPE on the rows of the pivot table
    I put the REVENUE in the measures of the pivot table
    Measure has the formula : RSUM("Facts Revenue".Revenue BY Customers."Customer Type")

  • Fpga - trying to use the RIO Replication VIs to replace Run at Reset Running FPGA

    Running LabVIEW 12.1
    We have an application that is using an FPGA that was compiled to Run at Reset (runs on any reset or powerup).  We occassionally need to update the image on the RT and FPGA and I have downloaded the NI RIO Replication VIs.
    The problem I am having now is that when I got to download the bitfile to the FPGA Flash on the sbRIO9636 I am getting the following error:
    Error -61141
    Possible reason(s):
    LabVIEW FPGA:  The operation could not be performed because the FPGA is busy. Stop all activities on the FPGA before requesting this operation. If the target is in Scan Interface programming mode, put it in FPGA Interface programming mode.
    My updater is stand alone EXE.  It may not be able to get a link to the FPGA because we can't be sure what Bitfile is currently on a particular system.  I tried using the Open FPGA Reference and loading a BLANK bitfile onto the FPGA by setting the FPGA to RUN when it his the FPGA Open Reference VI - and this works to allow me to erase the bitfile.  It does not allow me to immediately after run the Download bitfile VI from the RIO replication - even though I Close and Reset the FPGA before trying to download the Bitfile to the RIO Flash.
    Will I have to first Erase the existing bitfile and then load the new one?
    Ryan Vallieu
    Automation System Architect
    Solved!
    Go to Solution.

    The workflow is pretty simple.
    Connect to the sbRIO and send down a new Bitfile to the Flash and reset the unit.
    This works great if the sbRIO has nothing on it.  This works great if the FPGA code is encapsulated in the RT EXE and instantiated by the Open FPGA Reference.vi with RUN = TRUE.
    What doesn't work is the whole reason I need to send a new bitfile to the FLASH of the RIO in the first place.  FPGA RUN WHEN POWERED/RESET.  The Fpga code once put on the RIO Flash drive loads every time and runs great.  our RT Code Connects fine...
    Occassionaly we need to replace the RT and FPGA code.  Once the unit has been flashed once the with the FPGA, the NEXT time I want to Flash a NEW FPGA Bitfile onto the RIO Flash using the NI RIO Replication Toolkit VI: Download Bitfile.vi I get an error -61141 LabVIEW FPGA:  -61141: The operation could not be performed because the FPGA is busy. Stop all activities on the FPGA before requesting this operation. If the target is in Scan Interface programming mode, put it in FPGA Interface programming mode.
    I changed my code to shutdown the FPGA remotely by using a VI Server call into the RT.EXE....mabe I also need to close the Reference.  What kills me is that once again we are given VIs for replication that do not perform what can be done by the project and the stand alone RIO Device Setup.exe.
    Ryan Vallieu
    Automation System Architect

  • Display as Running Sum

    I have a measure in the pivot table with the following options enabled:
    - Show data as - Percent of - Section
    - Display as Running Sum
    Also, I have several sections in the pivot table.
    The measure result is correct, but when I add totals, I get a strange result. The total for the first section is 100%, for the second section is 200%, for the third section is 300%, and so on.
    Does everybody get this problem? How can I solve it?
    Thanks.

    I couldn't find a solution... I gave up using "Display as Running Sum" and I created in the criteria tab a formula to solve this (using RSUM BY).

  • Running Sum without analytic function

    Hi
    I have data like below
    Create table Test (Name Varchar(30),M Int, Y Int, Val Int);
    Insert into Test Values ('A',1,2011,2);
    Insert into Test Values ('A',2,2011,2);
    Insert into Test Values ('A',3,2011,2);
    Insert into Test Values ('A',4,2011,2);
    Insert into Test Values ('A',5,2011,2);
    Insert into Test Values ('A',6,2011,2);
    Insert into Test Values ('A',7,2011,2);
    Insert into Test Values ('A',8,2011,2);
    Insert into Test Values ('A',9,2011,2);
    Insert into Test Values ('A',10,2011,2);
    Insert into Test Values ('A',11,2011,2);
    Insert into Test Values ('A',12,2011,2);
    Insert into Test Values ('A',1,2012,2);
    Insert into Test Values ('A',2,2012,2);
    Insert into Test Values ('A',3,2012,2);
    Insert into Test Values ('A',4,2012,2);
    Insert into Test Values ('A',5,2012,2);
    Insert into Test Values ('A',6,2012,2);
    Insert into Test Values ('A',7,2012,2);
    Now based on above data I need to calculate running sum for past 18 Months. Condition is I can not use analytic function or Oracle specific SQL functions (for portability).
    I tries following SQL but it dint work
    select Name,rnk, SUM(val) from (
    SELECT a.Name,a.m,a.Y,b.val, count(*) rnk
    from Test a, Test b
    where (a.Name=b.Name and (a.M <= b.M and a.Y<= b.Y))
    group by a.Name,a.Y,a.m
    order by a.Name,a.Y,a.m
    ) abc
    group By Name,rnk
    Order by Name,rnk
    Can some one give suggastion.

    Hi,
    I don't see what your query or your desired results have to do with the last 18 months. Is the task here to show for a given month (July, 2012, for example) the total of the 18 months ending in that month (February, 2011 through July, 2012 in this case) for the same name? If so:
    SELECT       c.name, c.y, c.m
    ,       SUM (p.val)     AS running_total
    FROM       test     c
    JOIN       test     p  ON     ( ((12 * c.y) + c.m)
                   - ((12 * p.y) + p.m)
                   ) BETWEEN 0 AND 17
    GROUP BY  c.name, c.y, c.m
    ORDER BY  c.name, c.y, c.m
    ;Output:
    NAME                Y          M RUNNING_TOTAL
    A                2011          1             2
    A                2011          2             4
    A                2011          3             6
    A                2011          4             8
    A                2011          5            10
    A                2011          6            12
    A                2011          7            14
    A                2011          8            16
    A                2011          9            18
    A                2011         10            20
    A                2011         11            22
    A                2011         12            24
    A                2012          1            26
    A                2012          2            28
    A                2012          3            30
    A                2012          4            32
    A                2012          5            34
    A                2012          6            36
    A                2012          7            36

  • Running Sum on column total minus current month

    Hi all,
    Is it possible to get the running sum total value of all the months minus the current month value in the column function,as I need to display the same in the narrative view.
    Like RSUM(YTD(M-1)Value)...
    Presently this RSUM is not giving me the right value.
    I can also do the total for all the months minus the current month value.Can it be done at the column funtion?
    Regards
    Ashish

    Hi
    Can you elaborate a little..Did you mean I need to create one variable in the repository?
    YTD (M-1 Value) / (YTD Last Year M 0 Value)
    where M0 is current month and M-1 is previous month and value is a measure.
    Regards
    Ashish
    Edited by: Ashish21473 on Jan 7, 2011 3:38 AM

  • Running Sum on Sorted data & freeze panes?

    Hi all,
    Brand new to Web Intelligence XI, so learning whilst putting together first report, however need some guidance and help on the following. 
    I have a basic report which is sorted by highest ytd sales within the report and has breaks at each change in brand category.
    I need to be able to provide a running % cumulative total for each article within each brand category based on the highest ytd  sales.
    I have tried using the running sum formula but this does not give correct results due to the sort, as when this is taken off
    the formula is correct.  Have different varients of this after reviewing the forum but unfortunately still cannot get this basic calculation to work.
    My second question is that when viewing a lot of data, is it yet possible to freeze the headers in each column?
    Thanks in advance for any help given.
    Nick

    Freeze panes will be supported in BO 4.1 which is planned to be released in Q3 2013.
    Check the details below:
    http://scn.sap.com/community/businessobjects-web-intelligence/blog/2013/03/10/what-is-new-with-web-intelligence-bi-41-part-2-core-capabilities
    http://scn.sap.com/community/business-intelligence/blog/2013/01/31/sap-businessobjects-bi-41-update-and-bi4x-roadmap-asug-webcast-part-1
    http://scn.sap.com/community/business-intelligence/blog/2013/02/01/sap-businessobjects-bi-41-update-and-bi4x-roadmap-asug-webcast-part-2

  • Integrating a waveform to obtain a running sum of the amplitude

    I am trying to decide the easiest way to integrate a waveform. I have obtained a signal and done a series of waveform operations on it, not I need to sum up the amplitudes of the waveform. I am assuming that the best way to do this is going to be using some sort of integration. I can't seem to get a simple integrator to do this.
    Thanks for your help

    Here is a little more information about the application. I have used data aquisitions to aquire two AC voltage waveforms. I have rectified the waveforms, and summed the two waveforms together. Now I need to take a summation (running sum) of the resulting waveform. Accuracy is somewhat of a concern, as this running sum will be used to calculate a series of costs and usage characteristics.
    Hope this helps by giving an idea of what I am looking to do.
    I have tried to do the numeric integration, but I am having a problem getting the waveform to sample as needed. My other idea was to convert the waveform to (x,y) coordinates and work with that data. I'm not sure what the best way will be.

  • Help with a resetting running total

    Hi, I need help with a query that will have a running total that resets at certain points
    Version
    BANNER                                                                        
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production    
    PL/SQL Release 11.2.0.3.0 - Production                                          
    CORE  11.2.0.3.0  Production                                                        
    TNS for Linux: Version 11.2.0.3.0 - Production                                  
    NLSRTL Version 11.2.0.3.0 - Production sample data
    create table t ( stat varchar2(3)
                   , beg_dt date
                   , end_dt date
                   , dur    number);
    Insert into t  values ('ACT',to_date('01-JUL-2012','DD-MON-YYYY'),to_date('31-JUL-2012','DD-MON-YYYY'),31);
    Insert into t  values ('ACT',to_date('01-AUG-2012','DD-MON-YYYY'),to_date('31-AUG-2012','DD-MON-YYYY'),31);
    Insert into t  values ('ACT',to_date('01-SEP-2012','DD-MON-YYYY'),to_date('30-SEP-2012','DD-MON-YYYY'),30);
    Insert into t  values ('LOA',to_date('01-OCT-2012','DD-MON-YYYY'),to_date('25-OCT-2012','DD-MON-YYYY'),25);
    Insert into t  values ('LOA',to_date('26-OCT-2012','DD-MON-YYYY'),to_date('31-OCT-2012','DD-MON-YYYY'),6);
    Insert into t  values ('LOA',to_date('01-NOV-2012','DD-MON-YYYY'),to_date('04-NOV-2012','DD-MON-YYYY'),4);
    Insert into t  values ('ACT',to_date('05-NOV-2012','DD-MON-YYYY'),to_date('10-NOV-2012','DD-MON-YYYY'),6);
    Insert into t  values ('LOA',to_date('11-NOV-2012','DD-MON-YYYY'),to_date('30-NOV-2012','DD-MON-YYYY'),20);
    Insert into t  values ('LOA',to_date('01-DEC-2012','DD-MON-YYYY'),to_date('15-DEC-2012','DD-MON-YYYY'),15);
    Insert into t  values ('ACT',to_date('16-DEC-2012','DD-MON-YYYY'),to_date('31-DEC-2012','DD-MON-YYYY'),16);
    Insert into t  values ('LOA',to_date('01-JAN-2013','DD-MON-YYYY'),to_date('31-JAN-2013','DD-MON-YYYY'),31);
    Insert into t  values ('LOA',to_date('01-FEB-2013','DD-MON-YYYY'),to_date('05-FEB-2013','DD-MON-YYYY'),5);
    Insert into t  values ('LOA',to_date('06-FEB-2013','DD-MON-YYYY'),to_date('15-FEB-2013','DD-MON-YYYY'),10);
    Insert into t  values ('LOA',to_date('16-FEB-2013','DD-MON-YYYY'),to_date('25-FEB-2013','DD-MON-YYYY'),10);
    Insert into t  values ('LOA',to_date('26-FEB-2013','DD-MON-YYYY'),to_date('28-FEB-2013','DD-MON-YYYY'),3);
    Insert into t  values ('LOA',to_date('01-MAR-2013','DD-MON-YYYY'),to_date('10-MAR-2013','DD-MON-YYYY'),10);
    Insert into t  values ('ACT',to_date('11-MAR-2013','DD-MON-YYYY'),to_date('31-MAR-2013','DD-MON-YYYY'),21);
    Insert into t  values ('ACT',to_date('01-APR-2013','DD-MON-YYYY'),to_date('30-APR-2013','DD-MON-YYYY'),30);
    Insert into t  values ('LOA',to_date('01-MAY-2013','DD-MON-YYYY'),to_date('25-MAY-2013','DD-MON-YYYY'),25);
    Insert into t  values ('LOA',to_date('26-MAY-2013','DD-MON-YYYY'),to_date('31-MAY-2013','DD-MON-YYYY'),6);
    Insert into t  values ('LOA',to_date('01-JUN-2013','DD-MON-YYYY'),to_date('04-JUN-2013','DD-MON-YYYY'),4);
    Insert into t  values ('ACT',to_date('05-JUN-2013','DD-MON-YYYY'),to_date('30-JUN-2013','DD-MON-YYYY'),26);This is close.
    select stat
        , beg_dt
        , end_dt                            
        , dur
        , sum( case stat when 'LOA' then dur else 0 end ) over ( partition by stat order by beg_dt) tot1
    from t
    order by beg_dt
    STAT BEG_DT      END_DT      DUR TOT1
    ACT  01-JUL-2012 31-JUL-2012  31    0
    ACT  01-AUG-2012 31-AUG-2012  31    0
    ACT  01-SEP-2012 30-SEP-2012  30    0
    LOA  01-OCT-2012 25-OCT-2012  25   25
    LOA  26-OCT-2012 31-OCT-2012   6   31
    LOA  01-NOV-2012 04-NOV-2012   4   35
    ACT  05-NOV-2012 10-NOV-2012   6    0
    LOA  11-NOV-2012 30-NOV-2012  20   55
    LOA  01-DEC-2012 15-DEC-2012  15   70
    ACT  16-DEC-2012 31-DEC-2012  16    0
    LOA  01-JAN-2013 31-JAN-2013  31  101
    LOA  01-FEB-2013 05-FEB-2013   5  106
    LOA  06-FEB-2013 15-FEB-2013  10  116
    LOA  16-FEB-2013 25-FEB-2013  10  126
    LOA  26-FEB-2013 28-FEB-2013   3  129
    LOA  01-MAR-2013 10-MAR-2013  10  139
    ACT  11-MAR-2013 31-MAR-2013  21    0
    ACT  01-APR-2013 30-APR-2013  30    0
    LOA  01-MAY-2013 25-MAY-2013  25  164
    LOA  26-MAY-2013 31-MAY-2013   6  170
    LOA  01-JUN-2013 04-JUN-2013   4  174
    ACT  05-JUN-2013 30-JUN-2013  26    0 I need a running total of LOA stat that will reset itself with each break of ACT so that I get :
    STAT BEG_DT      END_DT      DUR TOT1
    ACT  01-JUL-2012 31-JUL-2012  31    0
    ACT  01-AUG-2012 31-AUG-2012  31    0
    ACT  01-SEP-2012 30-SEP-2012  30    0
    LOA  01-OCT-2012 25-OCT-2012  25   25
    LOA  26-OCT-2012 31-OCT-2012   6   31
    LOA  01-NOV-2012 04-NOV-2012   4   35
    ACT  05-NOV-2012 10-NOV-2012   6    0
    LOA  11-NOV-2012 30-NOV-2012  20   20
    LOA  01-DEC-2012 15-DEC-2012  15   35
    ACT  16-DEC-2012 31-DEC-2012  16    0
    LOA  01-JAN-2013 31-JAN-2013  31   31
    LOA  01-FEB-2013 05-FEB-2013   5   36
    LOA  06-FEB-2013 15-FEB-2013  10   46
    LOA  16-FEB-2013 25-FEB-2013  10   56
    LOA  26-FEB-2013 28-FEB-2013   3   59
    LOA  01-MAR-2013 10-MAR-2013  10   69
    ACT  11-MAR-2013 31-MAR-2013  21    0
    ACT  01-APR-2013 30-APR-2013  30    0
    LOA  01-MAY-2013 25-MAY-2013  25   25
    LOA  26-MAY-2013 31-MAY-2013   6   31
    LOA  01-JUN-2013 04-JUN-2013   4   35
    ACT  05-JUN-2013 30-JUN-2013  26    0 Any help would be appreciated, thanks.

    Hi,
    So, you want a separate total whenever there's an 'ACT'. That's what PARTITION BY is for. You need to add the number of ACTs already encountered (which I called act_cnt) to the PARTITION BY clause that gets you the SUM.
    We can get act_cnt using the analytic functions like COUNT or SUM, but, since one analytic function can't depend on another computed inthe same query, we need to use a sub-query to compute act_cnt.
    Here's one way:
    WITH     got_act_cnt     AS
         SELECT     stat, beg_dt, end_dt, dur
         ,     COUNT (CASE WHEN stat = 'ACT' THEN 1 END)
                  OVER (ORDER BY  beg_dt)   AS act_cnt
         FROM    t
    SELECT       stat, beg_dt, end_dt, dur
    ,       SUM (CASE stat WHEN 'LOA' THEN dur ELSE 0 END)
             OVER ( PARTITION BY  stat
                     ,                act_cnt     -- ***** NEW *****
                 ORDER BY      beg_dt
               )       AS totl
    FROM      got_act_cnt
    ORDER BY  beg_dt
    ;Are 'ACT' and 'LOA' the only possible values for stat? If so, the query above can probably be simplified.

Maybe you are looking for