Cumulative Totals...

I'm not quite the seasoned pro, but have been working with CF for about 5 years and usually can get it to do what I want.  I thought this would be relatively easy (and prob is to you) to add cumulative costs in the right column of a balance sheet type output, but it's kicked my butt long enough..lol
Just need it to sum cumulative costs of the items selected, in the order sorted. I've tried varying ways to get this to add and display like I need, dbqueries, loop indexes, using recordcount/currentrow calculations, etc, etc...no joy
Appreciate your time...really! 
<form...select...etc>
<cfquery name="getcosts" datasource="xxx">
SELECT *
FROM costs
ORDER by '#form.sortby#'
</cfquery>
<cfoutput query="getcosts">
*displays columns for #item_name#, #item_cost#, and cumulative cost* based on output sort order
</cfquery>

RLByrd78240 wrote:
<cfquery name="getcosts" datasource="xxx">
SELECT *
FROM costs
ORDER by '#form.sortby#'
</cfquery>
<cfoutput query="getcosts">
*displays columns for #item_name#, #item_cost#, and cumulative cost* based on output sort order
</cfquery>
I have some doubts about the clause ORDER by '#form.sortby#'. Does it actually work? should it at least be ORDER by #form.sortby# (without the quotes)? Test by dumping getcosts.
When grouping a set of records, you should use the order-by column of the query as the group attribute of the cfoutput tag. In other words, something like
<cfoutput query="getcosts" group="#form.sortby#">
To get cumulative costs, you could use a construction like
<cfset cumulative = 0>
<cfoutput>
blah blah blah
<cfset cumulative = cumulative + item_cost>
</cfoutput>  

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/

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

  • 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

  • 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 do I create a cumulative total for 3 or more cells in a new column

    Ok so in brief I have a formula in column E that goes C3+C5+D4
    what I would like is for column E to keep a running total , at the moment all it does is do the same indidual sum in each E cell
    I apologise as there is most likely something stupid I am missing but I am new to number
    any advice please
    Louise

    Louise,
    I am not following the formula you presented.  When you say running total my brain thinks of the math as :
    add all previous values up to, and including, the latest row.
    Like this:
    the result in cell C1 is just the sum of B1
    the result in cell C2 is the sum of B1 and B2
    the result in cell C3 is the sum of B1, B2 and B3
    the result in cell C4 is the sum of B1, B2, B3 and B4
    etc
    this can be realized with the formula:
    C1=SUM($B$1:B1)
    this is shorthand for... select cell C1, then type (or copy and paste from here) the formula:
    =SUM($B$1:B1)
    the formula means... sum all the cells from the absolute cell B1 ($B$1) to the relative cell B1.
    as you fill this formula down the absolute cell reference will not change but the relative cell reference will adjust
    to fill down... select cell C1, copy
    now select column C, paste

  • I need some help Regarding Cumulative totals

    Hi ,
    i have a requirement
    1) we have columns calender Periods and actual to date. The requirement is we need cumulate the actual to date. i have applyed RSUM function in column formula.
    2) it is working fine. But again the requirement is this cumulative solution is changed based on selected calender periods. but this is not expected.
    3) ex:-
    calender period actual Units Cumulative Units
    oct - 2010 10 10
    Nov-2010 9 19
    Dec-2010 15 34
    Jan-2011 25 59
    Feb-2011 12 71
    March-2011 19 90
    April - 2011 13 103
    May - 2011 18 121
    June - 2011 24 145
    this is the reqiurement but i have a Prompt Like
    i hve selected resource categery some xyz and stert period is Jan -2011 and end period is May - 2011
    the values disply's like bellow
    Resource Category start Period End Period
    xyz Jan - 2011 May - 2011
    Jan-2011 25 25
    Feb-2011 12 37
    March-2011 19 58
    April - 2011 13 71
    May - 2011 18 89
    But this is not actual cumulative units the actual value for Jan 2011 cumulative value is 59 not 25
    can any one help me regarding this issue
    regards,
    ramesh

    Hi,
    Refer this link abt iview properties & set authorization ...
    http://help.sap.com/saphelp_nw04/helpdata/en/13/81a66d100011d7b84b00047582c9f7/frameset.htm
    Color- you have to change portal theme...
    Width- create a new Loyout..
    Regards,
    Senthil K.

  • 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

  • Could I add Cumulative Totals in pivot table?

    for example
    08-1-1 08-2-1 08-3-1
    A 1 2 2
    B 1 2 2
    C 1 2 2
    Total 3 6 6
    CumuTotal 3 9 15

    I add a cummulative column in a table.
    In this column, I calculate the accumulated turnover for 2000 and 2001.
    But the function don't stop at the end of the year 2000.
    I want the function restart for 2001
    Turnover : Accumulated turnover :
    October : 5 : 5 :
    2000 November : 5 : 10 :
    December : 10 : 20 :
    January : 6 : 26 : <= I want 6 for this value
    2001 February : 20 : 46 :
    March : 10 : 56 :
    Thanks

  • Form with Cumulative Total

    Im new to this website and have built a couple of forms pretty easily. This is a great resource to get feedback. I need to build a form that along with their multi-choice answer function gives me a point total. For example:
    Question 1: =1 point
    Question 2: =1 point
    Question 3: =1 point
    And then at the end you automatically get a point total. Is that possible and if so what how do I make that happen?
    Thanks in advance

    On your side in the View Responses tab you can add formulas that do calculations. We do not support calculations in the actual form while it is being filled out.
    Randy

  • How to get Cumulative total

    hi
    I have two columns
    1Month
    2.amount
    Here is my records
    Month Amount
    Apr 10
    may 20
    jun 30
    jul 40
    I expect a result like the following
    Month Amount
    Apr 10
    may 20+10=30
    jun 60
    jul 100
    Regards
    Josh

    select month, sum(amount) over (order by to_date(month, 'mon'))
    from yourtab;
    Gints Plivna
    http://www.gplivna.eu

  • MIS report : Daily Cumulative Report for contract in SD module

    Hi All,
               Do you have any idea about MIS report in SD module.actually my requirement is that
    i have to generate daily cumulative report for contract. that means at time i am selecting ten plants
    and correspondingly sum of  total quantity,average rate and average weight of all the contracts for particular plant  should be displayed in a column and various existing flavours should be displayed in a row.
    for above requirement following output format is there:
    plant ->           plant1               plant2              plant3 ....   .....
    flavour             quantity  rate     quantity  rate
    cumulative
    total cumulative
    please refer sample code,if any.
    Thks & Regards
    Shailesh

    Hi,
    You can ask your functional people what are the required fields to develop a report below are the table.
    customer related tables:
    KNA1 Customer master General Data
    KNB1 Customer Master – Co. Code Data
    KNKK Customer Master Credit Control Area Data
    KNVV Sales Area Data
    KNVI Customer Master Tax Indicator
    KNVP Partner Function
    KNVD Output type
    KNVS Customer Master Ship Data
    KLPA Customer/Vendor Link
    Sales Documents
    VBAK Sales Document - Header Data
    VBAP Sales Document - Item Data
    VBUK Header Status and Administrative Data
    VBKD Sales Document - Business Data
    VBUP Item Status
    VBPA Partners
    VBFA Document Flow
    VBEP Sales Document Schedule Line
    VBBE Sales Requirements: Individual Records
    Delivery Document
    LIKP Delivery header table
    LIPS Delivery item table
    Billing document:
    VBRK Billing document header table
    VBRP Billing Document Item table
    Shipping
    VEKP Shipping Header Table
    VEPO Shipping Item Table
    Thanks
    VIkranth

  • Daily sales by month and cumulative sales for year

    Hi Experts,
    I have a reporting requirement where I have to show daily sales by month and cumulative daily sales for particular month for the year.
    e.g. If the current month is January then my result shows fine. see below
    Calendar Day
    Net Sales
    Target
    Sales Year
    Actual
    Target
    01/01/2014
    100
    90
    01/01/2014
    100
    90
    02/01/2014
    200
    180
    02/01/2014
    300
    270
    03/01/2014
    300
    290
    03/01/2014
    600
    560
    04/01/2014
    400
    350
    04/01/2014
    1000
    910
    But If I am in the month of Feb and I want to show sales for the month and cumulative sales for the year for just Feb but instead of showing cumulative total from 01/01/2014 to end of Feb it starts again at begining of Feb - See below
    e.g. 
    Calendar Day
    Net Sales
    Target
    Sales Year
    Actual
    Target
    01/02/2014
    200
    190
    01/02/2014
    200
    190
    02/02/2014
    400
    380
    02/02/2014
    600
    570
    03/02/2014
    600
    590
    03/02/2014
    1200
    1160
    04/02/2014
    800
    750
    04/02/2014
    2000
    1910 
    Expected Result - sales for the year shoud show cumulative result from 01/01/2014 - 31/12/2014
    Calendar Day
    Net Sales
    Target
    Sales Year
    Actual
    Target
    01/02/2014
    200
    190
    01/02/2014
    1200
    1100
    02/02/2014
    400
    380
    02/02/2014
    1600
    1480
    03/02/2014
    600
    590
    03/02/2014
    2200
    2070
    04/02/2014
    800
    750
    04/02/2014
    3000
    2820 
    How do I achive this?
    please help.

    What else you need?
    looks like you got #working days for the month, use that metric as of jan 15th

  • Project mat. proc. report with monthly breakup and cumulative for year

    Hi All,
    can any body suggest a report for  "Project material procurement report  with monthly breakup and cumulative total for a financial year "
    Thanks in Advance.
    Regards,

    Hi Ahmed,
    Thank you very much for the response.
    I am seeking the std sreport which can give the details for the project material consumption report with monthly breakup with the cumulative month total to year.
    ex. jan 10 units , june -10 units , nov 10 units, total (year) =30
    regards,

Maybe you are looking for

  • Imac 9,1 prohibitory sign at startup (no parking)

    I'm sure everyone is sick of reading about this, but I'm starting to think that this is an Imac 9,1 problem. Also, I'm not exactly a novice with repairing the usual OSX things. My job sometimes forces me do typical Tech stuff to other people's machin

  • Ovi maps - turn off

    Hi, Just wanted to discuss and get your feedback on when do you plan on including voice navigation and updated maps on N900, since its coming pre installed or easily downloaded on various other low cost phones by Nokia - when can we really enjoy Ovi

  • How to default value from popup page to main page.

    Hi, Requirement: I have a create page with table region of 10 lines.I have an icon for every line and on click of this icon, a popup window will be opened. In the popup window i have quantity field with a table region. User is allowed to select the q

  • Blackberry Bold freezes on start up

    Please help urgetly, my phone freezes halway through rebooting process. This happens even after performing two software updates.

  • I want to print grey type on black cover stock.

    I want to print grey type on black cover stock.  I'd like the type to be the equivalent of a 20% grey in PhotoShop.  I'm told setting the black (K) to 20% won't work.  How then do I get my grey?