Cumulative totals in report

Hi,
I've a table having customer code, customer name, dr_cr, amount fields
SELECT a.CUCODE, a.cuname, a.DR_CR,
decode(a.DR_CR,'D',a.AMOUNT) Debit,
decode(a.DR_CR,'C',a.AMOUNT) Credit,
nvl(decode(a.DR_CR,'D',a.AMOUNT),0)-nvl(decode(a.DR_CR,'C',a.AMOUNT),0) Total,
a.narration1
FROM Tablename a
ORDER BY a.CUCODE
I want to show cumulative totals for each row that is debit-credit amount. Is that possible, if yes, how?
Thanks and Regards,
Sudha.

Sudha,
You must have missed the analytical query that Denes had mentioned. You need to use SUM( ) OVER () to make things work. I have modified your query as below. There could be syntax issues, which you may have to fix.
SELECT x.CUCODE, x.cuname, x.DR_CR,
       decode(x.DR_CR,'D',x.AMOUNT) Debit,
       decode(x.DR_CR,'C',x.AMOUNT) Credit,
       x.Total,
       x.narration1,
       SUM(x.total) OVER () running_total
FROM (  
    SELECT a.CUCODE, a.cuname, a.DR_CR, a.amount,
           decode(a.DR_CR,'D',a.AMOUNT) Debit,
           decode(a.DR_CR,'C',a.AMOUNT) Credit,
           nvl(decode(a.DR_CR,'D',a.AMOUNT),0)-nvl(decode(a.DR_CR,'C',a.AMOUNT),0) Total,
           a.narration1
    FROM  Tablename a
) x
ORDER BY x.CUCODEYou may also want to read this article:
http://www.oracle.com/technology/oramag/code/tips2005/062005.html
Thanks.
Ravi

Similar Messages

  • Performance of cumulative total and caching

    Hi all
    I'm having some trouble with performance when using the cumulative total function from AWM in derived measures.
    For some of our measures we store a delta, i.e. the change from the previous actual and an initial state as the first delta. From this we can work out the actual value at any point by doing a cumulative total across the entire range. For this i've used the cumulative total function in the calculated measure wizard in the AWM.
    Would any one know the implementation specs for this algorithm?
    In the AWM XML it does not have an OLAP DML formula, instead it seems to use a bibeans definition with oracle.dss.selection.calcStep.TimeCumulativeTotalStep as some sort of working class.
    I expected from the 'step' function that the cumulative total would be worked out as we go i.e. work out total for 1st month, then for the second month take this result and add the delta from the second month. For third month add third month's delta to second month and so on. This would make the performance linear as you do one cache hit (for previous total) one read (for delta) and one calculation per month added.
    However i get these kind of numbers for years returned against query time.
    1 year- 1 second
    2 years - 5 seconds
    5 years - 46 seconds
    The results show non linear growth which when you do query over 10 years cripples the system.
    Its looking like the cube is either working out each total from scratch and as such later years must add up more deltas or the cached total is being missed (if using the algorithm above) and hence must be recalculated, resulting in the same behavior as above.
    NB i've fully aggregated my cube so no aggregation is being done up to the month/week level.
    Can anyone tell me what's going on here, is it a poorly coded algorithm or are there some settings in olap that i need to modify to improve performance?
    My recourse at the moment is to retrieve all the deltas and do my own linear cumulative total in pl/sql, however as other calculated measures rely on these totals, I'd have to recode all of our calculated measures in pl/sql which seems wholly redundant.
    I'm on 10.2.0.1, using an all sparse cube with compressed composites, time is my first dimension in the order.
    PS on my first run of doing the cumulative total in pl/sql i retrieved 10 years worth of deltas and totalled them in 0.2 seconds.
    This is opposed to 395 seconds for 10 years using the inbuilt olap function!
    Message was edited by:
    Block

    I think have seen this type of issue before where the calculated measures do create performance issues. This does seem to mainly affect time based calculations and I think this is because there is specific processing that occurs for time based calculations to manage the default time levels of day, week, month, quarter and year.
    It is possible to create your own custom formula via DML to perform a cum. total. However, you will need to create some additional objects within your AW to manage the relationships between the levels within your time dimension.
    Using the common schema sample that is shipped with BI10g I produced the following report:
    limit time to '1803';
    limit time add descendants;
    limit time keep time_levelrel 'CAL_MONTH';
    RPR DOWN TIME -
    W 30 TIME_LONG_DESCRIPTION -
    W 10 D 0 <CUMSUM(SALES_REVENUE, TIME, TIME.QTR) -
    CUMSUM(SALES_REVENUE, TIME, TIME.YR)>;
    This creates a running total for both quarter and years.
    January 03 2,077,440 2,077,440
    February 03 4,435,069 4,435,069
    March 03 6,093,747 6,093,747
    April 03 1,573,273 7,667,020
    May 03 3,285,001 9,378,748
    June 03 4,925,472 11,019,219
    July 03 1,891,216 12,910,434
    August 03 3,796,132 14,815,351
    September 03 5,827,050 16,846,269
    October 03 1,722,615 18,568,884
    November 03 3,441,748 20,288,017
    December 03 5,373,679 22,219,948
    this requires two additional dimensions and associated relations to manage the reset process:
    If you need quarterly balances:
    DEFINE time_quarter text dimension
    DEFINE TIME.QTR RELATION TIME_QUARTER <TIME>
    limit time to time_levelrel 'CAL_QTR'
    MNT TIME_QUARTER MERGE VALUES(TIME)
    limit time to time_levelrel 'CAL_MONTH'
    TIME.QTR=time_parentrel
    If you need yearly balances:
    DEFINE TIME_YEAR TEXT DIMENSION
    DEFINE TIME.YR RELATION TIME_YEAR <TIME>
    limit time to time_levelrel 'CAL_YEAR'
    MNT TIME_YEAR MERGE VALUES(TIME)
    limit time to time_levelrel 'CAL_MONTH'
    TIME.YR=TIME_PARENTREL(TIME TIME_PARENTREL)
    LIMIT TIME TO TIME_LEVELREL 'CAL_QTR'
    TIME.YR=TIME_PARENTREL(TIME TIME_PARENTREL)
    If you just need to create totals reset at the year level then the formula would be:
    CUMSUM(SALES_REVENUE, TIME, TIME.YR)
    I don't think I can post the XML for the custom calculation template into this posting as I think it gets filtered out. Send me an email ([email protected]) and I will send you the XML template for creating a custom calculation that can be imported into AWM.
    Hope this helps
    Keith Laker
    Oracle EMEA Consulting
    BI Blog: http://oraclebi.blogspot.com/
    DM Blog: http://oracledmt.blogspot.com/
    BI on Oracle: http://www.oracle.com/bi/
    BI on OTN: http://www.oracle.com/technology/products/bi/
    BI Samples: http://www.oracle.com/technology/products/bi/samples/

  • Cumulative totals question

    Hi
    I have a design question on cumulative totals.
    I have Material, Plant and 0CALDAY as Characteristics and Total receipts and Total demand as key figures coming from data source.
    On day1 I get beginning inventory from Material master. Ending inventory for day1 is Beginning inventory+Total receipts u2013 Total demand.
    On day2 beginning inventory will be day1u2019s ending inventory.
    I have to use Beginning inventory and Ending inventory in other calculations. I couldnu2019t do directly in BEx directly.
    Please give your suggestions how I can achieve this.
    Thank you
    Sree

    Hi Sree,
    This is the Forum ....
    I wud suggest this way...
    1)Create a query Via APD (Go thru APDs in case you are not aware)
    2)Store the data in a WO-DSO
    3)Create  a cube and push the data to cube via STD DSO with Key fields as Material, Plant and 0CALDAY.
    4)Do reporting from there.
    5)Create  a PC and trigger the data daily ,store the data in this flow.
    By this way we can store the data and do reporting on this.
    Cube>Query>APD>WO-DSO>STD-DSO>Cube>Query..
    Come back if u hve any issues....
    Rgds
    SVU123

  • Profit center accounting totals records report 2KEE:

    Hi,
    When I am executing Profit center accounting totals records report 2KEE for a specific selection as below,
    Record type: 0
    Version: 0
    Controlling area:
    Company code:
    Posting period :1
    Fiscal year:2007
    Profit center: 1000dummy
    Account:
    After report is generated and if drill down further, line items total is not matching with the report page, breakup gives different values but not the report value.
    I tried report even after implementing OSS 892779 and 952263 but the result is same.  I am using 4.7
    Request your help in this.
    Regards,
    Lakshmana Rao

    Dear Eugene,
    What do you mean? What is the report?

  • RUNNING TOTAL IN REPORTS

    Hi,
    Can any one tell me how to create a running total in Oracle reports. I have two fields pulled in the SQL called CR and DR. I want to do the running total at report level. Here what I want
    CR------DR-------RTOTAL
    20-----10---------10 ( here the RTOTAL Field is (20 - 10) )
    30-----15---------25 ( here the RTOTAL Field is (30 - 15) + 10)
    50-----25---------50 ( here the RTOTAL Field is (50 - 25) + 25)
    75-----35---------90 ( here the RTOTAL Field is (75 - 35) + 50)
    Thanks
    -Feroz

    Hello,
    You can use the following SQL query :
    select cr,dr,cr-dr cr_minus_dr from <table> ...
    and create a Summary Column in the Reports :
    Source : the field cr_minus_dr
    Function : Sum
    Regards

  • Total in report

    Title says it all. I would like to know how to do total in report.
    Thank you.

    Welcome to Oracle Forums!
    Please acquaint yourself with the FAQ and forum etiquette if you haven't already done so.
    Also, get yourself a friendlier handle, 974072 is not friendly
    Always state
    <ul>
    <li>Apex Version</li>
    <li>DB Version and edition</li>
    <li>Web server used.I.e. EPG, OHS, ApexListner Standalone or with J2EE container</li>
    <li>When asking about forms always state tabular form if it is a tabular form</li>
    <li>When asking about reports always state Classic / IR</li>
    <li>Always post code snippets enclosed in a pair of &#123;code&#125; tags as explained in FAQ</li>
    </ul>

  • Creating a cumulative total by day measure which resets each month.

    Hi,
    I need to creative a cumulative total measure (or calculated column) which accumulates my revenue sales for each day in a month, but resets each month.
    I've created an example below:
    The dates are from a linked date table and are based on a fiscal year.  When the months are collapsed the months can either accumulate or stay fixed to the max for the month, that does not affect me.
    I have tried various attempts using the guides below and I'm sure the answer is there but I can't get the filtering right.
    I can get it to work but accumulate since the start of my data but this is not what I need.
    http://www.daxpatterns.com/cumulative-total/
    http://javierguillen.wordpress.com/2012/11/28/running-total-techniques-in-dax/
    Thanks.

    It appears that your months align with the standard calendar's months. I.e. your fiscal calendar's October always aligns with regular October. If this is the case, then you can simply use the built-in time intelligence function TOTALMTD().
    MTD Measure:=
    TOTALMTD(
    [Measure]
    , DimDate[Date Field]
    If this is not the case and your month does not always line up with the standard calendar month, you can implement identical behavior with this FILTER():
    Custom MTD Measure:=
    CALCULATE(
    [Measure]
    , FILTER( ALL( DimDate )
    , DimDate[Month Number] = MAX( DimDate[MonthNumber] )
    && DimDate[Date Field] <= MAX( DimDate[Date Field] )
    Both of these will give identical behavior:
    At the day level, they will show the running total for the current month, including the current day.
    At the month level, they will show the total for the month.
    At the quarter level and above (semester, year, decade, ...) they will show the total for the last month in that period. E.g. for a standard year, they will show December's total.
    If these don't work, please provide more details about your date dimension, your data model, and how you are constructing your pivot table, preferably all in the form of a copy of your workbook on OneDrive or similar.

  • Cumulative value in reports

    Hi all,
    Is it possible to get cumulative values for a column in a report ,using a querry or crystalreport.
    Also how we can populate data or rows for which there was no transaction.
    Thanks

    Hi,
    You may check this thread to find your solution:
    Re: Running Total in QLD
    Thanks,
    Gordon

  • Cumulative YTD COPA Report

    Hello,
    We have requirement in copa report (ke30) wherein Year to date information should be available based on period range selected in input parameters.
    Say for example if user gives period range of Apr to June 2014 in ke30, then report should display cumulative values based on period selected.
    Report should be as per below format and value should be cumulative value as per period selected.
    Lead column
    1000
    2000
    3000
    4000
    Total
    Value Field 1
    1
    4
    7
    1
    13
    Value Field 2
    2
    5
    8
    2
    17
    Value Field 3
    3
    6
    9
    3
    21
    Value Field 4
    4
    7
    0
    4
    15
    where 1000 -4000 are profit center. For month wise details, i have created a separate report
    Regards
    Karthik

    Hi,
    create a form based report. In the column(s) where the YTD values should appear (or in the general data selection if valid for all values) define period from as "1" and period to as "local variable".
    It should look like this (no matter how the variable is named)
    The variable "PERIODBIS" is a selection variable in the report defined using KE31 and the form created is attached to this report.
    BR Christian

  • Totals in report header?

    I am using Crystal XI to develop a fairly simple financial report.  One of the requirements for the report is to have a copy of the totals located in the Report Header section.  It does not seem to be as simple as just putting the running total field in the header.  When I do that it does not evaluate properly and the result is incorrect.  What can I do to work around the limitation with Crystal?  Maybe I need to design a sub report that totals the information and then supress everything but the Report Footer section on the sub-report?

    Please try creating a sub report in the report header and assign the values to a shared variable and call the variable in the main report and place it in the below section of the sub report. And also note that you should not suppress the sub report instead suppress the sections inside the sub report and resize the sub report to smaller size.
    How do I create a shared variable in the sub-report?  Can you give me an example?  I'm not sure what you mean by placing the variable "in the main report" ... "below the section of the sub report".  Are you suggesting that I place both the sub-report, and the variable in the Report Header of the main report?  If so, why?  I imagine the variable would serve the same purpose as the sub-report.  In the case, I could just use one or the other.

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

  • Ssrs 2008 grand totals of report

    In an SSRS 2008 report, I am placing a grand total amount in the report footer since I want the amount at the very end of the report.
    The problem is when the report is exported to PDF, the amount is a long ways from where the detail lines are located at.
    Thus can you tell me how to make the data in the report footer change to be closer to the detail lines?

    In your report design make sure you remove as much white space as possible from the main body of the report

  • PO total value report

    Hi filks!!
    I want to have a PO report in which I want to see only the total value of the PO, and no PO line details.
    Is there any report..Please help.
    Best regards

    Hi everyone,
    I need the same for scheduling agreements instead of POs. Is this possible as well?
    Further I do need the line specific value and not the total one.
    I'd be really thankful for help!
    BR,
    Alex

  • How to calculate a cumulative total in HANA

    Hello,
    I have a detail table (e.g. GL line item table) which has entries for 'posting date', account number, year, month, posting amount (single key figure) and account type (whether the account is a profit & loss account or a balance sheet account.
    The requirement is to create a view which shows balance of month for profit and loss accounts and cumulative balance per month for balance sheet accounts (i.e. total of all line items till end of the month, not just for the month).
    Currently I am able to get only balance for the month , but not the cumulative balance.
    How can I calculate a cumulative amount column/key figure - either through Analytical view or calculation view?
    Thanks,
    Ninad

    The Window Functions should help. Here is a sample query in SPS06 using a sum over function against an SAP HANA Live standard view.
    SELECT Year("BillingDocumentDate_E") as "Invoice_Year", "BillingDocumentDate_E" as "Invoice_Date", round("TotalNetAmount_E") as "Billed_Amount",
           round(Sum("TotalNetAmount_E") OVER (partition by Year("BillingDocumentDate_E") order by "BillingDocumentDate_E")) as "YTD_Amount"
    FROM "_SYS_BIC"."sap.hba.ecc/BillingDocumentQuery"
    WHERE "SAPClient" = '004' and "SoldToPartyName" = 'Becker Berlin' and "BillingDocumentDate_E" >= '2002-01-01'
    GROUP BY Year("BillingDocumentDate_E"), "BillingDocumentDate_E", "TotalNetAmount_E"
    ORDER BY 1, 2
    Message was edited by: Marc Daniau

  • How to get the group totals in report

    HI,
    Iam generating a report to display Storage Location, and Unit of Measures and Material group and also group totals.
    how to display the group totals on the report.
    thank q
    rushi.

    Hi,
    This following report clearly explains how to display the subtotal and grand total of
    the particular field in alv.
    REPORT  YMS_ALVSUBTOTAL.
    *REPORT z_alv_sub_totals .
    TYPE-POOLS: slis.
    DATA: BEGIN OF it_output OCCURS 0,
              var1(8) TYPE n,
              var2(10),
              var3 TYPE I,
          END OF it_output.
    DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
           t_fieldcat TYPE slis_fieldcat_alv,
          it_sort TYPE slis_t_sortinfo_alv,
          t_sort TYPE slis_sortinfo_alv,
          v_repid LIKE sy-repid.
    INITIALIZATION.
      v_repid = sy-repid.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM sort_fields.
      PERFORM fill_fieldcat.
      PERFORM list_display.
    *&      Form  GET_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM get_data.
      it_output-var1 = 1000.
      it_output-var2 = 'anupama'.
      it_output-var3 = '10000'.
    it_output-key = 'X'.
      APPEND it_output.
      CLEAR it_output.
      it_output-var1 = 1000.
      it_output-var2 = 'siddhu'.
      it_output-var3 = '20000'.
      APPEND it_output.
      CLEAR it_output.
      it_output-var1 = 1000.
      it_output-var2 = 'chinni'.
      it_output-var3 = '100000'.
      APPEND it_output.
      CLEAR it_output.
      it_output-var1 = 2000.
      it_output-var2 = 'chicchu'.
      it_output-var3 = '10000'.
      APPEND it_output.
      CLEAR it_output.
      it_output-var1 = 2000.
      it_output-var2 = 'candy'.
      it_output-var3 = '10000'.
      APPEND it_output.
      CLEAR it_output.
      it_output-var1 = 1000.
      it_output-var2 = 'anupama'.
      it_output-var3 = '10000'.
      APPEND it_output.
      CLEAR it_output.
      it_output-var1 = 4000.
      it_output-var2 = 'anupama'.
      it_output-var3 = '10000'.
      APPEND it_output.
      CLEAR it_output.
    ENDFORM.                    " GET_DATA
    *&      Form  fill_fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM fill_fieldcat.
      PERFORM fill_fields USING: 'IT_OUTPUT' 'VAR1' 'Variable 1' ' ',
                                 'IT_OUTPUT' 'VAR2' 'Variable 2' ' ',
                                 'IT_OUTPUT' 'VAR3' 'Variable 3' 'X'.
    ENDFORM.                    " fill_fieldcat
    *&      Form  fill_fields
          text
         -->P_0146   text
         -->P_0147   text
         -->P_0148   text
         -->P_0149   text
    FORM fill_fields USING    value(tabname) TYPE slis_tabname
                              value(fieldname) TYPE slis_fieldname
                              value(seltext_m) LIKE dd03p-scrtext_m
                              value(do_sum) TYPE c.
      t_fieldcat-tabname = tabname.
      t_fieldcat-fieldname = fieldname.
      t_fieldcat-seltext_m  = seltext_m.
      IF do_sum = 'X'.
        t_fieldcat-datatype = 'CURR'.
      ENDIF.
      t_fieldcat-do_sum = do_sum.
      APPEND t_fieldcat TO it_fieldcat.
      CLEAR t_fieldcat.
    ENDFORM.                    " fill_fields
    *&      Form  list_display
          text
    -->  p1        text
    <--  p2        text
    FORM list_display.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         i_callback_program             = v_repid
         it_fieldcat                    = it_fieldcat
         it_sort                        = it_sort[]
       TABLES
          t_outtab                       = it_output
       EXCEPTIONS
         program_error                  = 1
         OTHERS                         = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " list_display
    *&      Form  sort_fields
          text
    -->  p1        text
    <--  p2        text
    FORM sort_fields.
      t_sort-fieldname = 'VAR1'.
      t_sort-tabname = 'IT_OUTPUT'.
      t_sort-spos = 1.
      t_sort-up = 'X'.
      t_sort-subtot = 'X'.
      APPEND t_sort TO it_sort.
      CLEAR t_sort.
      t_sort-fieldname = 'VAR3'.
      t_sort-tabname = 'IT_OUTPUT'.
      t_sort-spos = 2.
      t_sort-up = 'X'.
      APPEND t_sort TO it_sort.
      CLEAR t_sort.
    ENDFORM.                    " sort_fields
    Thanks,
    Sankar M

Maybe you are looking for

  • F4 help for a single field in interactive form

    Hi Experts, I am working in HRAS process.I created a Form Scenario and an Adobe Form.  I linked my interactive form in portal using standard Start Processes iView . Now I have to create a value help(F4 help) for 'STATE' field based on 'COUNTRY' field

  • Printing templates not functioning correctly.

    I printed (2) 7x5 Prints using template browser. The top print is getting clipped about a quarter inch. In the top left-hand corner both horizontal boxes are stating that the size is 7x5.  I have double checked all the settings. Using a Epson 4900 pr

  • Full Optimize Error - OutOfMemmory in SAP BPC

    Hello Has anyone come across the following error when running a full Optimize from SAP BPC Administration. Error Message: Exception of type system OutOfMemoryException was thrown. I've raised a support call but would appreciate any help on knowing wh

  • Issue with Crystal 11 and Activex Viewer

    Hi All,   We have been using Crystal Enterprise 10 for long without any issues, Recently we had to move to Crystal 11 as our clients are not able to buy Crystal 10 any more. The crystal Report is run from our product using the activex viewer .The Rep

  • Wierd problem. Windows update not working

    Seagate internal drive started acting flakey. Indexing was not working properly plus other things. Installed new drive and as i was loading drivers with lenovo updater around update 11 the indexer quits working. New drive is 500g hitachi I can use re