Cumulative total - how to have a footer cell give running total

I'm working on a gas mileage spreadsheet. One column shows how many miles I went between gas fill ups. I'd like the footer cell in that column to show the running total. I'm running into a problem with the empty cells - they're causing a red triangle error in the footer cell. What's the formula to keep a running total of a set of cells, but ignore any blank cells?
Thanks,
Don

Hi Yvan,
Thanks for your response. The cells in C are output from other formulas. I used =SUM(C) for the cell (which happened to be the C column, by the way) and got the red triangle error. Is there a way for the footer cell in C to disregard the embedded formulas and take the output of each column cell instead, and get a running total of that?
Thanks,
Don

Similar Messages

  • How to calculate a percentage of a Running Total?

    Post Author: pvang
    CA Forum: Formula
    Hi folks,    Quite new here to the forum and to Crystal Report. As you can tell, I've already stumbled upon a roadblock. Here is what I'm trying to do:I am grabbing employee names and the number of cases that they are working via a sql query. So the sql query will result in something like 'Bob', '403'; Bob being the employee and 403 being the number of cases he's working on. In the report, I have a running total that sums up the total number of cases. I want to determine the ratio of Bob's(and every other employee's) cases over the running total amount of cases. So, for demo purposes, Bob has 403 cases and the total amount of cases is 1612, Bob's ratio would be 25%(403/1612). The equation that I am using right now is: /{#RTotal})*100 and it is not working. The ratio starts at 100%(effectively because the running total after the first record is equal to his/her cases) and then drops off dramatically. I know why it is doing that, just don't want those results. I tried using the EvaluateAfter function to no avail. Is this possible? If so, how? Many thanks in advance.

    Post Author: rroberson
    CA Forum: Formula
    Sounds to me like you don't need to use a running total.  Just group on name (bob) and do a normal total (not running total) for the group (group summary).  You can just divide that group summary total by the grand total (another crystal summary) and mult by 100.

  • How to create crystal report 2008 with running totals?

    i want to create a report with running totals as follows:
    Balance B/F 1000.00
    Invoices     Receipts    Running B/ce
    100                            1100
                     500             600
                     500             100
    300                              400
                     400                0
    The B/F field is passed as a Parameter.

    Hi  panayiotis,
    In order to create a running total you need to have absolute clarity on the following:
    (i)Whether the running total be set on change of field/record/group.
    (ii)Whether the running total be set on change of record/group OR never.
    Make the appropriate choice.
    Apply this to the field to summarize and type of summary in Running Total Pane.
    Thanks,
    Amogh.

  • How to have Weblogic and BAM process run in background

    I ssh to the Weblogic (also the BAM) server via putty and use below command to start the weblogic and BAM:
    /opt/oracle/Middleware/user_projects/domains/base_domain/startWebLogic.sh
    /opt/oracle/Middleware/user_projects/domains/base_domain/bin/startManagedWebLogic.sh bam_server1
    And then I have no way to have the weblogic and BAM run in backgroup as it needs to ask me for login and password. I cannot close the ssh connection neither otherwise the weblogic and BAM processes will die
    Clay

    Hi Clay,
    Both these points can be easily handled.
    To start admin server enter the below command with the &. This & will make the process run in background.
    . /opt/oracle/Middleware/user_projects/domains/base_domain/startWebLogic.sh &
    If you want the logs to be redirected to some file then you can use a nohup as given below
    nohup . /opt/oracle/Middleware/user_projects/domains/base_domain/startWebLogic.sh &
    Same holds good for bam serevr also
    . /opt/oracle/Middleware/user_projects/domains/base_domain/bin/startManagedWebLogic.sh bam_server1 &
    OR
    nohup . /opt/oracle/Middleware/user_projects/domains/base_domain/bin/startManagedWebLogic.sh bam_server1 &
    It will respond to you with the process-id, you can just hit an enter and safely close the putty session while the server is still up & running.
    To stop the same, in a new putty session you can enter the below. Here you need not(will not) give &
    . /opt/oracle/Middleware/user_projects/domains/base_domain/stopWebLogic.sh weblogic welcome1 t3://hostname:port
    . /opt/oracle/Middleware/user_projects/domains/base_domain/bin/stopManagedWebLogic.sh bam_server1 t3://hostname:port
    Password:
    As you see above we are not passing user-id/password while starting the server. We need to create a file named boot.properties and place it in /opt/oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/security directory. security directoy will not be present, you have to create it.
    Contents of boot.properties file will be only 2lines as below
    username=weblogic
    password=welcome1
    On next startup server will encrypt the password.
    Same boot.properties file has to be created in /opt/oracle/Middleware/user_projects/domains/base_domain/servers/bam_server/security location.
    Hope this answers your question.
    Thanks,

  • Running total in report footer returning inaccurate result

    Post Author: smarkta
    CA Forum: Formula
    I am writing a report that contains 3 groups.  I have created running totals for each group that are accurate by selecting the group to evaluate and reset on.  now I need to basically sum the results of the all the group running totals but have had no success.  any tips on how to do this would be greatly appreciated.
    Thanks

    Post Author: Charliy
    CA Forum: Formula
    Were you doing a Distinct Count?  Did you have a formula on the Running Total?  What is there about the Group Totals that make them different than the final total.

  • 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

  • Running Total & Distinct Count Query

    Crystal 10.0.0.533 CR Professional
    Hope you can assist.
    I have a report listing deals signed, each deal has a corresponding category i.e. industry type, Accountant, Chiropractor, Financial Services, etc.
    I am undertaking a Distinct Count on these categories so that in the group footer it is showing number of different categories signed in a period (the report is grouped into different date periods). This is working OK.
    However, I need to EXCLUDE the category from this distinct count if the deal value is zero.
    I have tried using a formula to show a blank field if the value is zero, however it appears to be distinctly counting the blank as a category?
    Any assistance would be much appreciated.
    Tracy

    Deffinetly it will be less than what you expect for grand total. It is because when you are calculating distinct count for each group suppose
    Group A has categories A,B,C,D-->distinct count (4)
    Group B has C,D,E,F-->distinct count (4)
    but while calculating grand total then the distinct count will be
    A,B,C,D,E,F --> grand total (6) but not (8).
    In this case you need to use mannual running total like this
    whileprintingrecords;
    numbervar i;
    i:=i+{running total};
    place this in group footer and create another fomula like this
    whileprintingrecords;
    numbervar i;
    place this in report footer to get the correct grand total.
    Regards,
    Raghavendra

  • Manual Running Total vs Running Total

    Morning all,
    It is some what strange to me when I try to use a formula to calculate the total jobs and when I try to use Running total to count the same total jobs. Both answers in theory should be the same however they are not. I am wondering where am I going wrong in the manual formula.
    If {despatch_summary.job_type}="FSV" then
    if {despatch_summary.order_status}<>0 then
    {despatch_summary.order_no}
    else
    0
    The above code then gets DistinctCount ({@FSV})
    The same method if I use by using Running Total it gives the correct number of jobs.
    Running Total
    field to summarize : despatch_summary.order_no
    Summary Type: DistinctCount
    Formula: {despatch_summary.job_type}="FSV" and {despatch_summary.order_status}<>0
    Reset: none
    The formula gives me 513 where as the same running total gives me 514
    Where am I going wrong?
    Strangely it is adding 1 to all of my manual running totals (1 is coming from canceled orders).
    Many thanks
    Regards

    Sastry I am adding this formula into the crosstab which is setup by Number of days. So on the column it is number of days and on the summarized field it is this formula.
    I chose Group options and clicked on DistinctCount after adding the formula into the summarized field.
    I have already tried the formula you have suggested however it doesn't seem to be affecting it.
    Apart from that what I have just done is added the Running Totals to the Summarized field which is coming up correctly however now the problem is to get their percentages.
    I have used the following code but it doesn't seem to be working.
    Whileprintingrecords;
    Numbervar g:=Currentfieldvalue;
    Numbervar h:={@TotalJobs-CanceledJobs};
    Numbervar i:=0;
    i:=((g/h)*100);
    Numbervar gTot:=gTot+i;
    if gTot > 100 then "100.00%"
    else
    totext(gTot,2)+"%"
    I know I am doing it wrong when it comes to percentages. I need to get the percentages off that Running Total (Grand Total).
    Am not sure how to acheive that either.
    Many thanks
    Regards
    Jehanzeb

  • Running Total in Group Header

    Post Author: bahamaER
    CA Forum: Crystal Reports
    Hello, I have been reviewing threads for running totals and would like some assistance on creating a running total for a group with a condition that will display in the group header, the running total should also reset for each group. Is this possible?
    I know that there are some constraints such as the variable being reset to 0 in the header for each group as well as the group records have not been rendered when the header formulas are being assessed. I have been able to accomplish the task of running totals with conditions for groups using a running total field and also 3 separate formulas placed in the group header, detail and footer. The display is only correct in the group footer; my goal is to have the footer formula in the group header.  Any ideas?  I am currently using CR 8.5 but will be upgrading to CR 2008.
    Thankyou

    Hi,
    If you are trying to calculate Total and display it in Group Header for field value placed in Detail, then you will get incorrect/no value for total, as Crystal Reports prints/processes the report line by line and it will not be able to process the Total for field in Detail section in Group Header.
    Its is by Design.
    For a workaround:
    - Insert the same probematic report (Say A.rpt) as a Subreport in Group Header of this report(Say A.rpt).(Say in GroupHeader A1) and link the Main Report to the
    - Insert Section Below (Say GroupHeader A2)
    - Calculate Total in Section Group Header A2)
    This workaround will reduce the Performance of the report as Subreport will be proceed for each Group Value.
    Regards,
    Kiran

  • Running Total not working correctly

    I have a running total setup inside a for loop, the problem is that the running total isn't "running" . Below is the syntax
    <?for-each@section:xdoxslt:foreach_number($_XDOCTX,1,3,1)?>
    <?xdoxslt:set_variable($_XDOCTX,’DUPE’, xdoxslt:get_variable($_XDOCTX, ‘DUPE’ ) +1) ?>
    <?for-each-group@section:/ TMP008/LIST_G_ORDER_BY/G_ORDER_BY/LIST_G_INVOICE/G_INVOICE;G_INVOICE?>
    TABLE HERE+_
    <?end for-each?><?end for-each?>
    I am using this loop to print 3 copies of an invoice, then by using the running total I am trying to call a unique footer on each copy by having the following code in the footer.
    <?choose:?>
    <?when: xdoxslt:get_variable($_XDOCTX,’DUPE’)=”1”?>
    <?call:Footer1?>
    <?end when?>
    <?when: xdoxslt:get_variable($_XDOCTX,’DUPE’)=”2”?>
    <?call:Footer2?>
    <?end when?>
    <?otherwise:?>
    <?call:Footer3?>
    <?end otherwise?>
    <?end choose?>
    What is happening is the first copy is using Footer 3 and the other 2 copies are using Footer 1. FYI at the top of the rtf I have a import statement and set_variable statement as shown below:
    <?import:file:///C:\Documents and Settings\username\Desktop\MasterFooter.rtf?>
    <?xdoxslt:set_variable($_XDOCTX,’DUPE’, 0)?>
    The variable DUPE is getting the value 1 on every page which I don't quite understand.
    Any help would be greatly appreciated. I can attach the xml file and rtf if so desired. Thanks

    First initialise a variable and assign it value zero (with this code..)
    <?xdoxslt:set_variable($_XDOCTX, 'RunTotVar', 0)?>
    then embed the following code within the for loop where you want the running total displayed..
    the code below shows a running total for the xml field INVOICE_AMT
    <?xdoxslt:set_variable($_XDOCTX, 'RunTotVar', xdoxslt:get_variable($_XDOCTX, 'RunTotVar') + INVOICE_AMT)?><?xdoxslt:get_variable($_XDOCTX, 'RunTotVar')?>
    Hope this helps. its from one of the examples provided with the template builder for word.
    -Domnic

  • 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

  • Running total field which evaluates based on another running total field

    I'm figuring out how to use running totals in my reports.
    For each ProductCategory, there're many Products.
    For each Product, there're different ProductVersions.
    For each ProductVersion, it takes different Parts.
    My report should look like this
    Group1: ProductCategory (e.g. Catergory 1)
    Group2: Product (e.g. Product1)
    Group3: ProductVersion 1
    Details: Version 1: 3 * Part1 + 2 * Part2 + 4 * Part3
    GpFooter3: Total of 9 parts used
    Group3: ProductVersion 2
         Details: Version 2: 1 * Part1 + 2 * Part2 + 3 * Part3
    GpFooter3: Total of 6 parts used
    Group3: ProductVersion 3
         Details: Version 3: 2 * Part1 + 2 * Part2 + 3* Part3
    GpFooter3: Total of 7 parts used
    I've a running total at GpFooter3 to count number of parts, reset on change of Group3.
    But for each Product, I'm only interested in the details of the most recent version, that is the version with the greatest version number. So I hide all details and GpFooter3, and want to show
    GpFooter2: Product1, ProductVersion3, 7 parts
    How can I make a running total at GpFooter2 to select the ProductVersion which has the greatest version number among the Group "Product1"? The problem is, the number of versions for each Prodcut is not fixed, so I can't create a running total which evaluates on a particular version number. I tried to use a running total to obtain the maximum version number per Product, but I can't use this in the running total at GpFooter2 as a evaluation formula.
    Your help is much appreciated. Thank you very much.

    Create formula fields that are placed in Group Footer 3 that store the value(s) in global variables (basic syntax):
    global maxVersion as number
    global numParts as number
    maxVersion = {version}
    numParts = count({part}, {version})  ' Assuming grouped on {version}
    formula = ""
    Then use other formula fields to retrieve the values:
    global maxVersion as number
    formula = maxVersion
    And similarly for numParts...
    HTH,
    Carl

  • XI Sp2 running totals formula working strange

    Post Author: oskaratk
    CA Forum: Formula
    Hi,I seem to have a problem with a running totals formula:for totaling, in the detail band: formula "totalall"WhilePrintingRecords;CurrencyVar balance;CurrencyVar grs_amt;grs_amt :=  grs_amt + { detail.bal_grs_amt};balance := balance + { detail.bal_balance};'';  display in group footer:WhilePrintingRecords;
    CurrencyVar balance; in case the first record has a negative value, it is not subtracted from balance   if I switch the order the statements are executed
    balance := balance + { detail.bal_balance};grs_amt :=  grs_amt + { detail.bal_grs_amt};
    '';  balance is updated correctly also, in case I created a formula for each varible to be totaled, that works; like:formula "totalgrs_amt" WhilePrintingRecords;
    CurrencyVar grs_amt;
    grs_amt :=  grs_amt + { detail.bal_grs_amt};''; formula "totalbalance" WhilePrintingRecords;
    CurrencyVar balance;
    balance := balance + { detail.bal_balance};
    '';  Am I missing something, is this intended bahavior or maybe a bug? Thanks for any hintsOskar  

    I found that putting them in the footer works, but in the header does not.  Formula fields can summarize in the header.  But running total fields cannot???
    Thanks,
    W.

  • Filling gaps when calculate running total

    Hello Friends,
    i have a script that calculate running total,but i have gaps between dates.i had some solutions to resolve this issue but it did not perform well.because my source table has over milllion rows.please see my query,output and desired output.
    Thanks in advance.
    IF OBJECT_ID('tempdb..#SalesSummary') IS NOT NULL
    DROP TABLE #SalesSummary
    IF OBJECT_ID('tempdb..#StockDetail') IS NOT NULL
    DROP TABLE #StockDetail
    IF OBJECT_ID('dbo.SalesTransaction') IS NOT NULL
    DROP TABLE SalesTransaction
    IF OBJECT_ID('dbo.DesiredOutput') IS NOT NULL
    DROP TABLE DesiredOutput
    CREATE TABLE [dbo].[SalesTransaction] (
    [StoreKey] [int] NULL
    ,[StockKey] [int] NULL
    ,[OptionKey] [int] NULL
    ,[DateKey] [int] NULL
    ,[Quantity] [int] NULL
    CREATE TABLE [dbo].[DesiredOutput] (
    [Datekey] [int] NULL
    ,[StoreKey] [int] NULL
    ,[StockKey] [int] NULL
    ,[OptionKey] [int] NULL
    ,[SalesFlag] [int] NOT NULL
    ,[Quantity] [int] NULL
    ,[StockQty] [int] NULL
    INSERT [dbo].[SalesTransaction] (
    [StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[DateKey]
    ,[Quantity]
    VALUES (
    1
    ,1
    ,1
    ,20140601
    ,20
    INSERT [dbo].[SalesTransaction] (
    [StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[DateKey]
    ,[Quantity]
    VALUES (
    1
    ,1
    ,1
    ,20140603
    ,- 10
    INSERT [dbo].[SalesTransaction] (
    [StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[DateKey]
    ,[Quantity]
    VALUES (
    1
    ,1
    ,1
    ,20140607
    ,30
    INSERT [dbo].[SalesTransaction] (
    [StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[DateKey]
    ,[Quantity]
    VALUES (
    2
    ,2
    ,2
    ,20140602
    ,15
    INSERT [dbo].[SalesTransaction] (
    [StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[DateKey]
    ,[Quantity]
    VALUES (
    2
    ,2
    ,2
    ,20140603
    ,- 5
    INSERT [dbo].[SalesTransaction] (
    [StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[DateKey]
    ,[Quantity]
    VALUES (
    2
    ,2
    ,2
    ,20140605
    ,20
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140601
    ,1
    ,1
    ,1
    ,1
    ,20
    ,20
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140602
    ,1
    ,1
    ,1
    ,0
    ,0
    ,20
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140603
    ,1
    ,1
    ,1
    ,1
    ,- 10
    ,10
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140604
    ,1
    ,1
    ,1
    ,0
    ,0
    ,10
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140605
    ,1
    ,1
    ,1
    ,0
    ,0
    ,10
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140606
    ,1
    ,1
    ,1
    ,0
    ,0
    ,10
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140607
    ,1
    ,1
    ,1
    ,1
    ,30
    ,40
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140602
    ,2
    ,2
    ,2
    ,1
    ,15
    ,15
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140603
    ,2
    ,2
    ,2
    ,1
    ,- 5
    ,10
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140604
    ,2
    ,2
    ,2
    ,0
    ,0
    ,10
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140605
    ,2
    ,2
    ,2
    ,1
    ,20
    ,30
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140606
    ,2
    ,2
    ,2
    ,0
    ,0
    ,30
    INSERT [dbo].[DesiredOutput] (
    [Datekey]
    ,[StoreKey]
    ,[StockKey]
    ,[OptionKey]
    ,[SalesFlag]
    ,[Quantity]
    ,[StockQty]
    VALUES (
    20140607
    ,2
    ,2
    ,2
    ,0
    ,0
    ,30
    SELECT Datekey
    ,StoreKey
    ,StockKey
    ,OptionKey
    ,SUM(Quantity) Quantity
    INTO #SalesSummary
    FROM dbo.SalesTransaction
    GROUP BY Datekey
    ,StoreKey
    ,StockKey
    ,OptionKey
    SELECT Datekey
    ,StoreKey
    ,StockKey
    ,OptionKey
    ,1 AS SalesFlag
    ,Quantity
    ,SUM(Quantity) OVER (
    PARTITION BY StoreKey
    ,StockKey
    ,OptionKey ORDER BY Datekey ROWS UNBOUNDED PRECEDING
    ) AS StockQty
    INTO #StockDetail
    FROM #SalesSummary
    ORDER BY Datekey
    SELECT *
    FROM #StockDetail
    SELECT *
    FROM DesiredOutput

    I am glad that you attempted to post DDL, but you have no idea what you are doing and this is garbage. You have no idea what the ISO-11179 rules are. The meta-data attribute “_key” is never part of a data element name. Never! This is
    how the element is used, and not what it is by its nature. A silly world of only INTEGERs? No keys, no DRI, nothing that can be part of a data model. 
    Why not use an industry standard like GTIN for the items? But I am sure you did not research anything. 
    Why did you have one and only sales transaction? That your table name told us. Most transaction models have an identifier; look at the receipt you got from MacDonald's for the last hamburger you are. 
    Why not use an industry standard like GTIN for the items? But I am sure you did not research anything. 
    Why did you have one and only sales transaction? That your table name told us. Most transaction models have an identifier; look at the receipt you got from MacDonald's for the last hamburger you are. 
    This is a deck of punch cards written in bad SQL. 
    CREATE TABLE Sales_Transactions
    (sale_ticket INTEGER NOT NULL PRIMARY KEY, 
     store_nbr CHAR(10) NOT NULL, 
     gtin INTEGER NOT NULL, --- really CHAR(15)!  
     sale_date DATE NOT NULL, 
     sale_qty INTEGER NOT NULL
      CHECK (sale_qty <> 0));
    I have no idea how you get the unique ticket number for the key, but you can consider CREATE SEQUENCE Sales_Tickets; If you do not know this, Google it. You can build it into the DDL. 
    Did you know that RDBMS does not use Assembly language flags? We also do not use the Sybase “INTO #temp_table” to fake a scratch tape. In fact, you even mount another scratch tape so you can do step-by-step processing! This is not RDBMS. 
    You got the syntax for insertions wrong; you are using the old Sybase stuff. 
    INSERT INTO Sales_Transactions 
    (1, '00001', 1, '2014-06-01', 20), 
    (2, '00001', 1, '2014-06-03', -10), 
    (3, '00001', 1, '2014-06-07', 30), 
    (4, '00002', 2, '2014-06-02', 15), 
    (5, '00002', 2, '2014-06-03', -5), 
    (6, '00002', 2, '2014-06-05', 20);
    It looks like  you want inventory levels as running total
    This is a deck of punch cards written in bad SQL. 
    CREATE TABLE Sales_Transactions
    (sale_ticket INTEGER NOT NULL PRIMARY KEY, 
     store_nbr CHAR(10) NOT NULL, 
     gtin INTEGER NOT NULL, --- really CHAR(15)!  
     sale_date DATE NOT NULL, 
     sale_qty INTEGER NOT NULL
      CHECK (sale_qty <> 0));
    I have no idea how you get the unique ticket number for the key, but you can consider CREATE SEQUENCE Sales_Tickets; If you do not know this, Google it. You can build it into the DDL. 
    Did you know that RDBMS does not use Assembly language flags? We also do not use the Sybase “INTO #temp_table” to fake a scratch tape. In fact, you even mount another scratch tape so you can do step-by-step processing! This is not RDBMS. 
    You got the syntax for insertions wrong; you are using the old Sybase stuff. 
    INSERT INTO Sales_Transactions 
    (1, '00001', 1, '2014-06-01', 20), 
    (2, '00001', 1, '2014-06-03', -10), 
    (3, '00001', 1, '2014-06-07', 30), 
    (4, '00002', 2, '2014-06-02', 15), 
    (5, '00002', 2, '2014-06-03', -5), 
    (6, '00002', 2, '2014-06-05', 20);
    My guess is that yoyu can use: 
     CREATE VIEW Inventory_Levels
    AS
    SELECT sale_date, gtin, sale_qty,
           SUM(sale_qty) 
           OVER (PARTITION BY gtin
           ORDER BY sale_date
           ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) 
           AS current_stock_qty
      FROM Sales_Transactions 
     GROUP BY sale_date, gtin, sale_qty;
    --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

  • 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?

Maybe you are looking for

  • Down payment based on the purchase order

    i raise one purchase order 1000 Rs  in t code me21n after popup with number.  based on purchase order i pay advance amount 500 Rs with reference of purchase order number (in  f-48 i have given number reference field). when i saw the purchase oder (me

  • No movies via S-video

    On a T-40, I just tried to play a DVD movie onto a TV via the S-video port.  I can get the TV to display the T-40 screen (when set to 640x480, 16 bit), but when a movie plays on the T-40, the movie "screen" blacks out on the TV, regardless of whether

  • Will the Airport Express pass 24/96 audio?

    Does the airport express support 24 bit audio? Anything higher? I've looked all over and can't seem to get a definitive answer.

  • My firewire port works with ext hd but not with audio interface

    2010 Imac 21.5 running 10.8.5. My firewire port works with ext hd but not with audio interface. The local authorized Apple tech said that I need a new motherboard, but my firewire ext drive works perfectly. I don't understand. Thanks.

  • XPATH not reading my xml properly.

    <?xml version="1.0"?> <xml class="1" index="0" xmlns="http://www.blablabla.com/lsr/blablalba"      xmlns:testBase="http://www.blablabla.com/lsr/blablalba" service="localservicepreordering">      <header>           <testBase:interfaceid>testid</testBa