Running total and Next function in Crosstab

<strong><font size="3"><font face="Times New Roman">Clarifications on getting Next Running sum and count on a Crosstab</font></font></strong><font face="Times New Roman" size="3"> </font> <p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Here is the example, which I am working on:</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Highlights of the Report:</font></p><p style="margin: 0in 0in 0pt 0.5in; text-indent: -0.25in; tab-stops: list .5in" class="MsoNormal"><font face="Times New Roman"><span><font size="3">-</font><span style="font: 7pt &#39;Times New Roman&#39;">         </span></span><font size="3">Report is grouped on {Scenario Name}</font></font></p><p style="margin: 0in 0in 0pt 0.5in; text-indent: -0.25in; tab-stops: list .5in" class="MsoNormal"><font face="Times New Roman"><span><font size="3">-</font><span style="font: 7pt &#39;Times New Roman&#39;">         </span></span><font size="3">Left side dates on any of the tables is {Version Date}</font></font></p><p style="margin: 0in 0in 0pt 0.5in; text-indent: -0.25in; tab-stops: list .5in" class="MsoNormal"><font face="Times New Roman"><span><font size="3">-</font><span style="font: 7pt &#39;Times New Roman&#39;">         </span></span><font size="3">Dates on the top header on any of the tables is {Fsc Week End Dt}</font></font></p><p style="margin: 0in 0in 0pt 0.5in; text-indent: -0.25in; tab-stops: list .5in" class="MsoNormal"><font face="Times New Roman"><span><font size="3">-</font><span style="font: 7pt &#39;Times New Roman&#39;">         </span></span><font size="3">Other formulae used in this report are:</font></font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">1) = ({Query1.Demand Qty})/100000</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Numerical values displayed in the "Original values" table.</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">2) =</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">if {Query1.Scenario Name} = &#39;DLYPRD:ASCP-PRD:PRD&#39; </font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">THEN mid ({Query1.Scenario Name},13,3)</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">ELSE mid ({Query1.Scenario Name},13,6)</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Second column with value PRD in any of the tables.</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">3) {next qty} = if not onlastrecord then next({@ShortDemandQty}) else 0;</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">(used in the "next values vertically" table)</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">4) - running total to calculate horizontally</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Evaluate - For each record</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Reset - On change of field: {Version Date}</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">5) - running total to calculate vertically.</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Evaluate - For each record</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Reset - On change of field: {Fsc Week End Dt}</font></p><font face="Times New Roman" size="3"> </font> <p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">In this report design, when I go and change the Sort order in the Record Sort Expert, some of the values go for a toss. I got two cases where the vertical values are correct in one case and horizontal values are correct in another case.</font></p><font face="Times New Roman" size="3"> </font><strong><font size="3"><font face="Times New Roman">First Case:</font></font></strong> <p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Cumulative vertical values are correct.</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal">&#160;</p><font face="Times New Roman" size="3"> </font><strong><font size="3"><font face="Times New Roman">Second Case:</font></font></strong> <p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Cumulative horizontal values are correct.</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal">&#160;</p><font face="Times New Roman" size="3"> </font><strong><span style="color: blue"><font size="3"><font face="Times New Roman">Is there any way to consistisize both the horizontal and vertical running totals. I even tried forcing the evaluate & reset like below and clearing the record sort order, but it did not work:</font></font></span></strong><strong><span style="color: blue"><font face="Times New Roman" size="3"> </font></span></strong> <p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">1) - running total to calculate horizontally</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Evaluate - On change of field: {Fsc Week End Dt}</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Reset - On change of field: {Version Date}</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">2) - running total to calculate vertically.</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Evaluate - On change of field: {Version Date}</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">Reset - On change of field: {Fsc Week End Dt}</font></p><font face="Times New Roman" size="3"> </font><strong><span style="color: blue"><font size="3"><font face="Times New Roman">And one more observation on the running total, how it works in the crosstab is, the total runs likes a spiral rather than resetting at the column or row level. Is there any way to restrict this?</font></font></span></strong><font face="Times New Roman" size="3"> </font> <p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">3) {next qty} = if not onlastrecord then next({@ShortDemandQty}) else 0;</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">(used in the "next values vertically" table)</font></p><font face="Times New Roman" size="3"> </font> <p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">For example, onlastrecord does not seem to work on the "next values vertically" crosstab, rather brings the record from the next column.</font></p><p style="margin: 0in 0in 0pt" class="MsoNormal"><font face="Times New Roman" size="3">For 3/7/2007 - 01/APR/07, the value is 157.84 which is incorrect and should be 0.</font></p><strong><span style="color: blue"><font size="3"><font face="Times New Roman">I need to get a next on the running total. Next (fld) doesnot work for running totals. Please guide me, how to get the next values for the running total fields.</font></font></span></strong>

Post Author: redtop6683
CA Forum: Formula
Whoops I guess I should have mentioned that I've already tried using Sum and Round(Running Total, 2) and haven't had any luck.
I also should have mentioned that Groupings 1 and 2 are sums, and that Running Total is a running total that changes on every change of the grouping.  There are 4 groupings.
Grouping 1 (Employee Name)
Grouping 1.1 (Shift)
Grouping 1.2.1 (Payroll Department Code)
Grouping 1.2.1.1 (Description)
Below these 4 groupings is where the running total is.  The issue is that in the footer of grouping 1 is a field that sums the elapsed hours for the particular employee by each payroll department code, these are then summed using the running total.  The issue is as stated in the earler post that I can round these individual sums on the groupings, but I get the number on my running total to round differently as you can see by the earlier post's example.
Thanks for the help.
~Jason

Similar Messages

  • How to Summarized Running Total and Formula ????

    Post Author: ryan_r
    CA Forum: Crystal Reports
    Hi my name is Ryan, I want to ask something. I have build a report
    that contains Running totals and Formula. What I want to do is I want
    to use subtotal and Summary field for the running total and Formula,
    but I can find the field when I click the dropdownlist in the Subtotal
    dialog box or summary field for the running total and the formula. Is
    there any way that I can use subtotal or summary field for Running
    Totals and formula, I do need some help guys, Thanks. FYI: I use Visual Studio.NET 2003; ASP.NET(C#).regards

    Post Author: ryan_r
    CA Forum: Crystal Reports
    Hi kcheeb, thanks for your advice but it doesn't work sorry. By the way maybe I can explain you more of twisted situation.I have updated my report,
    so im not using runningtotals any more, I'm using summary field and
    formula which are;-the summary field is "Sum of SuspenseVoucher.Realisation" located in Group Footer #3: SuspenseMstr.ProgramID-The formula is "@Balance_Formula" which contain:{SuspenseMstr.Budget}
    - Sum ({SuspenseVoucher.PenggunaanBudget}, {SuspenseMstr.ProgramID})
    also located in the same location as summary field above.FYI: I have three group records which are:-Group #1 : SuspenseMstr.APDate (Appearing in months e.g January 2007)-Group
    #2 : programCategoryMstr.programCategoryID (doesn't have any objects I
    just put some dashed line, the group is only for proper sorting)-Group #3: SuspenseMstr.ProgramIDwhat I want to do is:-in the Group Footer #3, I already put "Sum of SuspenseVoucher.Realisation" and "@Balance_formula"-in
    the Group Footer #2, I want to put Summary of Budget but there's a
    problem in here too, in the budget field there are some data are
    conditionally suppressed. I already tried to put some summary field but
    the summary operation wasn't like what I wanted. What I wanted was the
    sum only evaluate the data that appeared in the report not the
    suppressed, but in the summary the suppressed data keep evaluated. And
    in this location I also want to put Summary of "Sum of
    SuspenseVoucher.Realisation" and the Sum of the @Balance_formula.-
    in the Group Footer #1, I want to add some Summary of "Sum of Budget"
    (which I already explained that this operation has a problem) and I
    also want to put the Sum of "Summary of Sum of
    SuspenseVoucher.Realisation" and the Sum of "Sum of @Balance_formula"-And in the Report Footer I want to add some Grand Total from all of the evaluation above.So
    there are my problems, quite much I would say. I hope this explanation
    helping all of you guys to solve my problem, thanks for spending your
    valuable time for me. This matter is really important for me 'cause I
    want to learn something new from all of you experts as I'm still a
    "toddler" in this situation and also because I work in this field, so a
    BIG thank you for all of you guys out there. Best Regards.

  • Running Total and In Current Year Columns Source

    Hi all,
    What is the source for Running Total and In Current Year Columns from Absence Detail Screen.
    From Which tables can I get the information on those columns.
    Thanks in Advance

    Hello,
    I am still struck with Running Total Column
    When i fetch running total using this query it works for some of the employees
    SELECT SUM(ABSENCE_hours) from PER_ABSENCE_ATTENDANCES where person_id = <your person id> and absence_attendance_type_id = <your absence type id>
    As there are three different cases here as Days,Hours and No Balance
    I am missing the logic again here when it comes for no balance and days
    Thanks

  • Running Totals and Formulas with Cross Tabs

    Hi,
    I'm using Crystal Reports 2008 and am having two issues using Cross Tabs.
    The first is that I want to have two crosstabs. They both will have a common Y axis (Oppourtunity.Sales Rep), and on the Y Axis I want one to show all (Opportunity.Create Date) where (Opportunity.Staus = Won) and the other where (Opportunity.Staus = In Process), but I can't figure out how to contruct the formula to return this result.
    The other issue, is that in addition to summarizing based on Sum (Opportunity.Expected Revenue), I would also like to create a running total to show the cumulative (Expected Revenue) Week over Week.
    Any direction would be fantastic.
    Thank you,
    Michael

    Please go through the SAP Notes listed here which would help you how to create mannual running totals in crosstab
    [https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_ossnotes&query=runningtotalin+crosstab&adv=true&note_number=&component=&sdn_updated_on_comparator=GE&sdn_updated_on=&sortby=cm_rnd_rankvalue]
    Regards,
    Raghavendra

  • SSRS Prior and Next Functions

    I have several reports in Hyperion that I use the next and prior functions to look at the row right before and/or the row after.
    To do this, I sort the data in a certain way to make sure the prior or next functions in hyperion find the right rows above or below the current row. For example, I may sort 2 other rows to get the right sorting for the functions to work correctly.
    Now I would like to be able to find a way to recreate these reports in Access and SSRS.
    I have been looking for a way to accomplish this in either or both.  But at the moment I have not found a way.
    If I need a unique field to help with this, I can concatenate between about 4 fields to make a column that has a unique key for each row.
    Could anyone point me at a good article or know how to do this?  I would really appreciate it very much, thank you!

    Hi grahamtribe,
    Based on my research, there is no such next function in Reporting Services. We can use custom code with VB code to write a function to achieve the similar goal. For more details, please see:
    Add Code to a Report (SSRS)
    Alternatively, if you have any concern about this, please submit a feedback at
    https://connect.microsoft.com/SQLServer/Feedback. Connect site is a connection point between you and Microsoft, and ultimately the larger community. Your feedback enables Microsoft to make software and services the best that they can be, and you can learn
    about and contribute to exciting projects.
    Thank you for your understanding.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Cummulative total and rank function

    Hi,
    I'm using Discoverer 3.1.36 and wondering if there is a way to
    get cumulative totals with Discoverer and how
    For i.e
    column A      column B      column C
         AB          50          50
         BC          100          150
         MB          70          220
    Also how to create the report that will show only top X values
    and has rank column too
    For i.e
    Rank     Column A
    1 50
    2 30
    3 15

    try importing your own sql statement for using the rank
    function. you may have to export sql first (to create the sql
    file), then edit it and import it.
    to get rank, you can try something like this:
    SELECT "User Name", "Number of whtvr"
    FROM
    (SELECT t1.username "User Name", COUNT(*) "Number of whtvr",
    RANK() OVER (ORDER BY COUNT(*) DESC nulls last) rank
    FROM table1 t1, table2 t2
    WHERE t1.userid=t2.userid
    AND t1.date BETWEEN t2.start_date AND t2.end_date
    GROUP BY t1.username)
    WHERE rank <= 10
    ORDER BY "Number of whtvr" DESC;
    try adding another column to assign a number to each row for the
    rank, maybe a sequence generated number, if a rank column (from
    the subquery) doesn't work.

  • Running total and calc between two column (subtraction)

    Hi Experts!,
    I have a simple requirement but getting me frustrated :( I need to calculate stock on a series of transaction
    this is my order table:
    OrderNo | Item | Delivery | OrderQty
    A-101 | G001 | 20110721 | 200
    A-104 | G001 | 20110722 | 300
    A-102 | GA02 | 20110721 | 210
    and my stock table :
    Item | stockQty
    G001 | 300
    GA02 | 0
    What i want to accomplish is something like this:
    OrderNo | Item | Delivery | OrderQty | StockOut
    A-101 | G001 |20110721 | 200 | 200
    A-104 | G001 |20110722 | 300 | 100
    A-102 | GA02 |20110721 | 210 | 0
    i believe there is must be a way to accomplish this, without using to create extra dummy table to store
    qty of Stock out (stock-orderqty),
    waiting for respons,
    Thanks!

    Try this
    with order1
    as
    select 'A-101' orderno, 'G001' item, 20110721 delivery, 200 orderqty from dual union all
    select 'A-104', 'G001', 20110722, 300 from dual union all
    select 'A-105', 'G001', 20110723, 250 from dual union all
    select 'A-102', 'GA02', 20110721, 210 from dual union all
    select 'A-103', 'GA02', 20110721, 300 from dual
    ), stock
    as
    select 'G001' item, 600 stockqty from dual union all
    select 'GA02', 500 from dual
    select orderno, item, delivery, orderqty, case when qty <= stockqty then orderqty else stockqty - qty1 end stockout
      from (
             select orderno, item, delivery, orderqty, qty, nvl(lag(qty) over(partition by item order by orderno), 0) qty1, stockqty
               from (
                      select orderno, o.item, delivery, orderqty, sum(orderqty) over(partition by o.item order by orderno) qty, stockqty
                        from order1 o
                        join stock s
                          on o.item = s.item
           )Note: Tables defined in the WITH caluse are sample table to show you how the SQL works. You can just use the SELECT statement with your original table.

  • Running Total in Crosstab

    Hello all,
    I've been unable to find any solutions for my issue, and I'm desperately hoping someone smarter than me can help me out. I'm trying to create a running total across columns for a crosstab report.
    The report looks like the following, as best as I can format it:
    (date) JAN-09 FEB-09 MAR-09 APR-09
    7 7 24 13 &lt;--
    (order type) (order #)
    Sales Order ACK12342 -4 -3 0 -1
    AHSKFD34 -2 -3 -2 0
    SSJDHD23 0 0 0 -10
    SJDDG1298 -5 0 0 0
    KDJD20937 -7 -8 0 0
    Work Order WO12620 9 0 0 0
    WO12827 8 7 0 0
    WO13743 3 7 19 0
    Stock N/A 5 0 0 0
    I want a running total of each month column. I've added the running total row I'm trying to create above. I haven't been able to create a running total that will give that to me.
    I hope this is enough information. I'll post answers to any followup questions.
    Thanks.
    EDIT: I apologize for the crosstab layout. I've butchered it, and I don't know how to go about making it more readable.
    Edited by: user3537345 on Sep 19, 2008 8:35 AM

    Hi Rod,
    Appreciate your response. Unfortunately, the solution you've posted doesn't go quite far enough.
    Your function does give me the running quantity, but it creates a new column for each OrderNumber, and then sums it. I've looking for a sum of all OrderNumbers (i.e., the whole column). Each column represents a month. So it's a running total of OrderNumbers, by Month. Hope that makes sense.
    I might be attempting to do something that can't be done in Discoverer. I'm just trying every suggestion I can get. I'm hoping it's something I've missed.
    I'll continue to experiment with your suggestion.
    Thanks.

  • Count and Sum running total

    Can i sum and couunt running total in formula?.
    Please let me know.

    Hey, we can do count and sum functions in Running total.
    These functions are available in crystal reports for  summary fields.
    We can create  the running total based on the type of summary like Sum, count, max, min, distinct count, etc.
    We can do Evaluation for each record or on group or on each field  and also be done by writing a formula.
    We can  do count or sum by manual running total by writing a formula in the formula workshop.
    Based on our requirement we can use both functionalities.
    Please let me know  if you have any queries.
    Regards,
    Naveen.

  • Problem with "Running Total"

    Hi, I've created a calcution using the analytic function template "Running Total" and the worksheet ran fine. I saved the workbook with this new calculation.
    The next day when I attempt to run that worksheet I received the error "Database Error - ORA-00923 From keyword not found where expected."
    For some reason it's loosing the SUM( ) from the calc.
    Here's what the calc looks like now -> No of Queries OVER(PARTITION BY Calendar Year and Month ORDER BY Calendar Date ASC ROWS UNBOUNDED PRECEDING )
    This is what it looks like when I created it -> SUM(No of Queries) OVER (PARTITION BY Calendar Year and Month ORDER BY Calendar Date ASC ROWS UNBOUNDED PRECEDING)
    Brent.

    Well, I guess my thought process was declaring warrBaseYrPrc in the @currWarrBaseYrPrc formula which would make it a global variable and accessible to all formulas where that same variable is declared. I thought that if I declared warrBaseYrPrc in @currWarr2YrPrc, it would have its value as calculated in @currWarrBaseYrPrc and use that. And since @currWarr2YrPrc returns the variable warrBaseYrPrc with some slight modifications depending on the if statment, it shouldn't have refused use in the Running Total.
    So I'm kind of leaning more toward an ordering screw up (i.e. it didn't know what formula to evaluate first because they were all in the same section and dependent on one another because of nesting formula invocations, and thus treated @currWarr2YrPrc warrBaseYrPrc variable, and subsequent calculations, as a constant as you talked about and you can't RT constants). I still find it perplexing why it would treat a variable as a constant, but I guess I'll have to experiment with it a little bit.
    By the way, do you know of any good free crystal report debugging tools?

  • Running totals: Custom Reset via Formula? (VS 2005)

    Post Author: PunchngMrGrumpy
    CA Forum: .NET
    Hi All,I have attached a screenshot to help make up for my inability to describe the situation I'm dealing with here.I
    have three groups within a report that currently use distinct Running
    Totals fields that Reset at the group levels that I assigned. I am
    attempting to create a single Running Totals field for all 3 groups
    that will reset depending on which Group is being calculated at the
    moment so that I don't have to have 3 separate Running Totals object
    for each and every group. I'm not sure how to do this or write this
    formula as I'm new to Crystal Reports and am used to SQL Reporting
    Services where this evaluation is automatically done for you (I was
    spoiled I guess).For example, if the Running Totals field
    control is in Group #1, I want it to reset at Group #1, and Group#2 to
    reset at Group #2, etc without having to create a field for each group.So
    basically I'm attempting to use a formula to create a Reset point (view
    screenshot for detail) that is determined by which group the data is
    being calculated in. Is this possible? I realize that it is possible by
    simply creating a new running total object for each group and telling
    it to reset on change of group specified, but this seems completely
    redundant and overly time consuming for larger reports where there are
    multiple groups and a lot of Running totals fields.I'm developing the report with Crystal Reports within Visual Studio 2005 if that helps any.I
    don't know if you'll be able to see it, but I have a screenshot link to
    explain what I'm trying to do. http://www.codeguru.com/forum/attachment.php?attachmentid=19302Thanks!

    Hi Abhilash,
    Thanks for the code, but the totals aren't right still yet.
    Also, I just noticed my running total is not functioning properly.  Count be the reason for my delima.
    Any suggestions on how to get the running total to function properly?
    What I just noticed is:
    Date               Patient          Count
    7/9/13             Patient A       7
    8/8/13             Patient B       8
    8/8/13             Patient B       8
    8/8/13             Patient C       8
    8/8/13             Patient D       8
    8/15/13           Patient E       9
    Would I be better off to do a formula vs a running total?

  • Running Total Variation Query Time Optimization

    Hi all, 
    I've been struggling with this query for a while. I need to set a customer specific running total for 10 million rows (reset for every customer). But every time the number goes negative, I need to set it as zero.
    For example,
    member no              amount            wallet
    member1                 400                      400
    member1                 -500                     0
    member1                  200                    200
    member2                  700                    700
    member2                 -200                    500
    Query:
    DECLARE @member float
    DECLARE @prev_member float
    DECLARE @amount float
    DECLARE @wallet float
    DECLARE db_cursor CURSOR FOR  
    SELECT [Member no], [Transaction Amount] 
    FROM [wallet_master_3]
    ORDER BY [Member No], [rownum]
    FOR UPDATE
    OPEN db_cursor
    FETCH NEXT FROM db_cursor INTO @member, @amount
    SET @prev_member = @member
    set @wallet=0
    WHILE @@FETCH_STATUS = 0
    BEGIN   
           IF @prev_member <> @member set @wallet=0
           SET @wallet = @wallet + @amount
           IF @wallet < 0 SET @wallet = 0
           UPDATE [wallet_master_3] SET walletsize = @wallet
           WHERE CURRENT OF db_cursor
           set @prev_member=@member
           FETCH NEXT FROM db_cursor INTO @member, @amount
    END   
    CLOSE db_cursor   
    DEALLOCATE db_cursor
    I've tried using a cursor. In five minutes, it ran 17,000 rows but after running it for 15 hours, the code only manages to set the running total for 175,000 rows. I'm not exactly sure why. Is there a faster approach I can use? 
    Thanks!

    As an exercise a 'Quirky Update' may help you in this scenario. Try the below trick!
    DECLARE @Wallet AS TABLE
    MemberNo VARCHAR(10),
    RowNum INT,
    Amount INT,
    Wallet INT
    INSERT INTO @Wallet (MemberNo, RowNum, Amount) VALUES
    ('member1',1, 400),
    ('member1',2, -500),
    ('member1',3, 200),
    ('member2',1, 700),
    ('member2',2, -200)
    DECLARE @RunTotal AS INT
    UPDATE W1
    SET
    @RunTotal = W1.Wallet =
    CASE
    WHEN W1.RowNum = 1 THEN W1.Amount
    WHEN @RunTotal + COALESCE(W1.Amount, W2.Amount) < 0 THEN 0
    ELSE @RunTotal + COALESCE(W1.Amount, W2.Amount)
    END
    FROM @Wallet W1
    LEFT OUTER JOIN @Wallet W2
    ON W1.MemberNo = W2.MemberNo AND W2.RowNum = W1.RowNum - 1;
    SELECT * FROM @Wallet;
    RESULT
    MemberNo RowNum Amount Wallet
    member1 1 400 400
    member1 2 -500 0
    member1 3 200 200
    member2 1 700 700
    member2 2 -200 500
    You can read more on 'Quirky Update' in below articles
    Solving the Running Total and Ordinal Rank Problems - Jeff Moden
    Robyn Page's SQL Server Cursor Workbench
    NOTE: Please test it thoroughly before using in a production environment!
    Krishnakumar S

  • Calculate % on manual running total??

    I have a three part manual running total that prints the final value in the report footer.  That total is based on groups of cities and time spent by each city on a project.  I'm trying to calculate the percentage of time they spent on the total project in each cities group footer.  So, of course (citytime % totalprojecttime).  However, since it's a manual running total it's calculating based on the time up until that point, so the first city is always at 100% because the manual running total and time spent by that city is always equal.  Then the next percentage is only based on the first two cities total divided by that current city, etc. so that the only city that actually has a correct percentage is the last one because it's finally calculated the totals at that point.
    I've tried various printing states (evaluate after, etc) but those aren't going to work because the total isn't done until the end.  Without doing a subreport, is there anyway to calculate that properly?

    If you can't do a simple summary to derive total time for City, then you will need to develop a hidden subreport which you place in city group header, and use that total calculate total city time. You can then use a shared variable to holding the total city time to calculate your %ages.
    Hidden subreport is a subreport will all sections suppressed and minmised so that it does not appear, it must be held in an unsuppressed section, you can section to underlay to ensure minimum space taken up.
    Ian

  • Calculating Running Totals in Columns

    I am trying to calculate running totals in Dynamic columns
    I have data that is monthly and want to create a running total in the columns.
    Data Format in:
    Material|Type|Month|Qty
    Query Report Ex:
    Material|Type|          Nov-05|     Dec-05|     Jan-06|     Feb-06
    PART1|  DEMAND|            -42 EA|     -46 EA|     -33 EA|     -3 EA
    PART1|  SUPPLY|          58 EA|       0 EA|   0 EA|     49 EA
    Result|          |       16 EA|     -46 EA|     -33 EA|     46 EA
    I would like running total taken from totals from previous columns + current column total are dynamic:
    Result|          |       16 EA|     -30 EA|     -63 EA|     -17 EA
    .continues for more parts
    PART2
    Thanks,
    Mike Walker
    FMC Technologies Inc.

    I am still having problems with this.
    I have not figured out a way to control the Results row that is genereated to be a running total.  Without having the data also becoming a running total.
    I am wanting an new running total line.  And not the standard Results row unless I can make it a running total and it leaves the data alone.
    Material|Type| Nov-05| Dec-05| Jan-06| Feb-06|....<Dynamic>
    PART1| DEMAND| -42 EA| -46 EA| -33 EA| -3 EA|....<Dynamic>
    PART1| SUPPLY| 58 EA| 0 EA| 0 EA| 49 EA|....<Dynamic>
    Standard Results Row:
    Result| | 16 EA| -46 EA| -33 EA| 46 EA
    I want this.  Running total of the standard results.
    Result| | 16 EA| -30 EA| -63 EA| -17 EA
    I will look more on this next week.
    Thanks.

  • ALV Grid Control -  Modifiy data in total and subtotal lines

    Hello all,
    I´am creating a report using ALV Grid Control. This report calculates (using delivered and returned materials) for each vendor/material-combination the return quote.
    Using the totals and subtotals function for different characteristics I want to calculate the return quote for the selected characteristic. Example:
    Material delivered returned quote
    ..4711 . . . 500 . . . 5 . . . . 1 (=returned*100/delivered)
    ..4711 . . . 400 . . . 10 . . . . 2,5
    . SUM . . . 900 . . . 15 . . . . 3,5 <-- 3,5 is the sum but I want display the calculated value 1,667
    Is there a possibility to modify data in the total and subtotal lines.
    Thank you for your answer
    Best regards
    Thomas

    you said instead of 3.5 you want to show 1,667 ..
    how is it possible...
    3,5 become 1,667
    i thought you are doing any conversions...
    vijay

Maybe you are looking for

  • Anyone have an Answer for the ipad Hotspot problem in Australia

    Anyone have an Answer for the ipad Hotspot problem in Australia

  • Fade In/Out not working

    Hi Applying Fade Ins or Outs seemed to have stopped working. Using either the crossfade tool or specifying them in the Inspector, they appear graphically correct, but audio-wise, no fade. Crossfading between regions is working fine. Using ordinary un

  • Debugging in JDev91, "Error: Unable to find fdebug.exe"

    Hi, I'm using JDev9i in Windows2000. When I try to debug my software JDev9i says; "Error: Unable to find fdebug.exe". I have checked all security settings of my folders, (as someone proposed here to some one else, who had problem which was also linke

  • Collector Configuration for Cisco LMS

    Hi, I have a cisco LMS 3.2 , what collectors need to be configured inorder to get the critical alarms such as HighBroadcast Rate in network

  • Error -9672 while adding networked printer

    While trying to add a networked HP 3600n color laserjet to the printer list (via Bonjour) on a 10.5.6 G4 Macbook I always ended up with 'an error occurred while trying to add the selected printer' with a -9672 error code. After much deleting of print