Running total of outputs

Hi i have a list of 11 numbers as a cfoutput, i need a
running total but the problem i have is not all 11 numbers will be
selected
ie
No 1 = 2000
No 2 = 5000
No 3 = 7000
No 4 = 7000
No 5 = left blank
No 6 = 7000
No 7 = 7000
No 8 = left blank
No 9 = 7000
No 10 = 7000
No 11 = 7000
Total = needs to be No1+No2+No3 etc this needs to be an
output as well
the error i get is can not be converted this is because of
the left blank numbers how would i do this
Many thanks

If the list of numbers is coming from a query, Q of Q should
fix you right up.

Similar Messages

  • Running total of calculated field in pivot

    VERSION: ORACLE 11
    TABLE:
    create table chart_detail (
    DIS        NUMBER,
    BLD_MO VARCHAR2(7),
    BLD        NUMBER(10),
    RPLC      NUMBER(10));DATA:
    insert into chart_detail values (60,'2011-03',0,2);
    insert into chart_detail values (150,'2011-04',10572,0);
    insert into chart_detail values (120,'2011-04',26449,5);
    insert into chart_detail values (30,'2011-04',0,1);
    insert into chart_detail values (60,'2011-04',0,7);
    insert into chart_detail values (90,'2011-04',0,9);
    insert into chart_detail values (120,'2011-05',5714,0);
    insert into chart_detail values (90,'2011-05',24557,1);
    insert into chart_detail values (60,'2011-05',0,4);
    insert into chart_detail values (30,'2011-05',0,0);
    COMMIT;EXPECTED RESULTS:
         2011-04                    2011-05               
    DIS     RPLC     BLD     TBLD     IPTV     RPLC     BLD     TBLD     IPTV
    30     1     0     37021     0.03     0     0     30271     0.00
    60     7     0     37021     0.22     4     0     30271     0.13
    90     9     0     37021     0.46     1     24557     30271     0.17
    120     5     26449     37021     0.59     0     5714     5714     0.17
    150     0     10572     10572     0.59               0     
    180               0                    0     
    TOTAL     22     37021               5     30271          PROBLEM: I need to have a running total of IPTV like in the above example. I can get the IPTV for each DIS/bld_mo but I don't know how to get the running total of it. In the script below I just used an example where I tried summing the IPTV like was done for build. I know it can't be done that way because IPTV is a calculated field in the query but if I substitute "APR_IPTV" with the formula for IPTV I get an error that window functions aren't allowed here. I do not know a way around this. I commented out the bad piece of code.
    PROBLEM SCRIPT:
    WITH  pivot_results  AS
      SELECT    dis
      ,    NVL (apr11_rep,  0)  AS apr11_rep
      ,    NVL (apr11_bld,   0)  AS apr11_bld
      ,    NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS apr11_tbld
    ,      DECODE(NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(apr11_rep, 0)*1000/ NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS apr11_iptv               
    ,      NVL ( SUM (apr11_iptv)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS apr11_tiptv  
      ,    NVL (may11_rep,  0)  AS may11_rep
      ,    NVL (may11_bld,   0)  AS may11_bld
      ,    NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS may11_tbld
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_iptv
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_tiptv               
      FROM     chart_detail
      PIVOT     (  MAX (rplc)  AS rep
              ,  MAX (bld)  AS bld
              FOR  bld_mo   IN ( '2011-04'  AS apr11
                                             , '2011-05'  AS may11
    SELECT    CASE
            WHEN  GROUPING (dis) = 0
            THEN  TO_CHAR (dis)
            ELSE  'Total'
        END      AS dis
    ,    SUM (apr11_rep)  AS apr11_rep
    ,    SUM (apr11_bld)  AS apr11_bld
    ,    SUM (apr11_tbld) AS apr11_tbld
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (apr11_iptv)
        END      AS apr11_iptv
    ,    SUM (apr11_tiptv) AS apr11_tiptv
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (apr11_tpiptv)
        END      AS apr11_tiptv
    ,    SUM (may11_rep)  AS may11_rep
    ,    SUM (may11_bld)  AS may11_bld
    ,    SUM (may11_tbld) AS may11_tbld
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (may11_iptv)
        END      AS may11_iptv   
    FROM    pivot_results
    GROUP BY  ROLLUP (dis)
    ORDER BY  pivot_results.dis
    ;Thank you,

    Hi,
    So you know how to compute iptv for an individual row; the problem now is that you want to get a running total of iptv; is that it?
    The problem there is that computing iptv requires an analytic function, and analytic functions can't be nested. To get the results of nesting f (g (x)), where f and g are analytic funtions, you have to compute g in a sub-query, and then use the results as the argument to f in a super-query.
    Here's how to apply that to your situation:
    WITH  pivot_results  AS
         SELECT    dis
    -- April, 2011
           ,           NVL (apr11_rep,   0)  AS apr11_rep
           ,           NVL (apr11_bld,   0)  AS apr11_bld
           ,           NVL ( SUM (apr11_bld)
                                       OVER (ORDER BY dis DESC)
                          , 0
                          )               AS apr11_tbld
         ,      NVL ( 1000 * apr11_rep
                              / NULLIF ( SUM (apr11_bld) OVER (ORDER BY dis DESC)
                                          , 0
                   , 0
                   )               AS apr11_iptv
    -- May, 2011
           ,           NVL (may11_rep,   0)  AS may11_rep
           ,           NVL (may11_bld,   0)  AS may11_bld
           ,           NVL ( SUM (may11_bld)
                                       OVER (ORDER BY dis DESC)
                          , 0
                          )               AS may11_tbld
         ,      NVL ( 1000 * may11_rep
                              / NULLIF ( SUM (may11_bld) OVER (ORDER BY dis DESC)
                                          , 0
                   , 0
                   )               AS may11_iptv
           FROM     chart_detail
           PIVOT    (    MAX (rplc)  AS rep
                    ,    MAX (bld)   AS bld
                    FOR  bld_mo   IN ( '2011-04'  AS apr11
                                      , '2011-05'  AS may11
    SELECT    CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  TO_CHAR (dis)
                  ELSE  'Total'
               END      AS dis
    -- April 2011
    ,           SUM (apr11_rep)  AS apr11_rep
    ,           SUM (apr11_bld)  AS apr11_bld
    ,           SUM (apr11_tbld) AS apr11_tbld
    ,           CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  ROUND ( SUM (SUM (apr11_iptv))
                                          OVER (ORDER BY  dis)
                      , 2
               END      AS apr11_iptv
    -- May 2011
    ,           SUM (may11_rep)  AS may11_rep
    ,           SUM (may11_bld)  AS may11_bld
    ,           SUM (may11_tbld) AS may11_tbld
    ,           CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  ROUND ( SUM (SUM (may11_iptv))
                                          OVER (ORDER BY  dis)
                      , 2
               END      AS may11_iptv
    FROM      pivot_results
    GROUP BY  ROLLUP (dis)
    ORDER BY  pivot_results.dis
    ;Output:
          APR11  APR11   APR11  APR11 MAY11  MAY11   MAY11  MAY11
    DIS    _REP   _BLD   _TBLD  _IPTV  _REP   _BLD   _TBLD  _IPTV
    30        1      0   37021    .03     0      0   30271    .00
    60        7      0   37021    .22     4      0   30271    .13
    90        9      0   37021    .46     1  24557   30271    .17
    120       5  26449   37021    .59     0   5714    5714    .17
    150       0  10572   10572    .59     0      0       0    .17
    Total    22  37021  158656            5  30271   96527As you can see, this is not quite what you wanted on the row where dis='150'. You asked for NULLS in the may11_rep, may11_bld and may11_iptv columns. You can get those results if you need them; just explain the rules that govern whether to display the values and when to display NULL.
    The way you posted the sample data and results, and the quantity of sample data were all excellent; it really helped me find a solution. Thanks.
    It would have also helped it you had explained how iptv is computed. Basically, iptv = 1000 * rep / tbld, right?
    It looks like most of this code:
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_iptvwas a way of avoiding divide by 0 errors; it would have been helpful if you had explained that.

  • Running Total of a Calculated Member

    Hi Friends ,
    Need help  in calculating the Running Total of a calculated member . I am using the below Query to calculate but it is not showing correct Values.
    Query :
    WITH
    set
    [FUNCTIONAL BENEFITS]
    as
    ORDER(
    [FUNCTIONAL BENEFITS].[FUNCTIONAL BENEFITS].children,[Measures].[ANNUAL UNIT CASES WEIGHTED VALUE]
    ,DESC)
    member  AUCWEIGHT as
    [Measures].[ANNUAL UNIT CASES WEIGHTED VALUE],
    FORMAT_STRING='##0.0'
    member
    [Running Total]
    AS
    SUM({null:[FUNCTIONAL BENEFITS].[FUNCTIONAL BENEFITS].CurrentMember},[Measures].[ANNUAL UNIT CASES WEIGHTED VALUE]),
    FORMAT_STRING='##0.0'
    MEMBER [Measures].[AUCWV_PRCT] AS
    ([Running Total]/[Measures].[TotalSuM])*100,
    FORMAT_STRING='##0.0'
    member  [CummalativePercent] as
    (SUM({null:[FUNCTIONAL BENEFITS].[FUNCTIONAL BENEFITS].currentmember},[Measures].[AUCWV_PRCT]))
    SELECT {
    AUCWEIGHT,[Running Total],
    [Measures].[TotalSuM],[Measures].[AUCWV_PRCT],[CummalativePercent]}on columns,
    NON EMPTY ([FUNCTIONAL BENEFITS])
    DIMENSION PROPERTIES PARENT_UNIQUE_NAME ON rows
    FROM [RRMiningDS1_CUBE]
    Output :
    DiMENSION
    AUCWEIGHT
    RunningTotal
    TotalSum
    AUCWV_PRCT 
    CUMMULATIVEPERCENT
    CORRECTCUMMULATIVEPERCENT
    A
    62605.4
    661634.6
    1345632.2
       49.2
    1271.2
    49.2
    B
    38587.9
    425278.7
    1345632.2
       31.6
    545.5
    80.8
    C
    35894.5
    370057.9
    1345632.2 
       27.5
    485.2
    108.3
    D
    30246.4
    48345.3
    1345632.2
       3.6
    4.9
    111.9
    The CUMMALITIVEPERCENT is coming wrong .
    I have mentioned the Correct CummulativePercent. as it should be the Running sum of AUCWV_PRCT i.e
    49.2+31.6+27.5+3.6=111.9
    Please help . where i am making the mistake
    Thanks
    Rakesh k Dhar

    Hi R,
    It might be as simple as adding solve_order = 99 to the cumulative calc. This tells the formula engine to do the cumulative calculation after the %.
    Richard

  • Crystal report running total balance

    Hi guys, please help me.
    im creating a report using crystal report that display running balance from subreport.
    i do have subreport and add it to main report but i need it real time changing.
    for example
    TRANSACTION TYPE                    QTY_IN               QTY_OUT          RUNNING BALANCE
    RECEIVED                                        1                         0                         1
    RECEIVED                                        2                         0                         3
    SHIP OUT                                         0                          1                         2
    SHIP OUT                                         0                          1                         1
    RECEIVED                                        1                         0                          2
    diagram shows the needed output of the report. please help. thanks

    hi sir abhilash, i know you know how to fix this, maybe i need to provide some more information about the report: here what i did:
    created formula @QTY_IN where code is:
                                  if {ITRN.TRANTYPE} = 'DP' then
                                      {ITRN.QTY}
                                  else
                                  if{ITRN.TRANTYPE}='AJ' then
                                 (if {ITRN.QTY} >=0 then {ITRN.QTY}) else
                                  0
    create formula @QTY_OUT
                                  if{ITRN.TRANTYPE}='AJ' then
                                 (if {ITRN.QTY} >=0 then 0 else
                               {ITRN.QTY}) else
                                  if{ITRN.TRANTYPE}='WD' then
                            {ITRN.QTY}
                             else 0
    create running total fields for @QTY_IN And @QTY_OUT
                             total_qty_in and total_qty_out
                             sum the fields and resets every change of group.
    create a formula(running) based on your suggetion
    create running_total_reset code is
                                  WhilePrintingRecords;
                                  numbervar rt := 0;
    paste it to group header.
    the output is
                                      in               out             running
    shipment              0                -4               146116
    shipment             0                 -1               146117
    shipment               0               -4               146116
    but it should be
                                      in               out                            running
    shipment              0                -4    (-146118)           146114
    shipment             0                 -1    (-146114)           146113
    shipment               0               -4     (-146113)          146109
    so on so forth.
    we can do this sir. thanks ^__^.
    really appreciate your help.

  • RUNNING TOTAL

    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

    Hi Bernd ,
    I tried this and here is the result.
    Query :
    SELECT MAIN_AC_CODE, JV_NO_T, JV_DATE_T, JV_DR_AMT, JV_CR_AMT, SUM(JV_DR_AMT - JV_CR_AMT) OVER ( PARTITION BY MAIN_AC_CODE ORDER BY MAIN_AC_CODE,JV_NO_T) RUNNING_TOTAL
    FROM FIN_JV_T WHERE MAIN_AC_CODE = 1102071001
    ORDER BY MAIN_AC_CODE, JV_NO_T , JV_DATE_T
    output :
    MAIN_AC_CODE     JV_NO     JV_DATE     DR_AMT      CR_AMT     RUNNING_TOTAL
    1102071001      JV1      05-JUL-06 6000      0           -11650
    1102071001      JV1      05-JUL-06 0           17650      -11650
    1102071001      JV13      15-JUL-06 15000      0           12750
    1102071001      JV13      15-JUL-06 30000      0           12750
    1102071001      JV13      15-JUL-06 7000      0           12750
    1102071001      JV13      15-JUL-06 0           30200      12750
    1102071001      JV13      15-JUL-06 1500      0           12750
    1102071001      JV13      15-JUL-06 1100      0           12750
    1102071001      JV14      16-JUL-06 1100      0           16358
    1102071001      JV14      16-JUL-06 2508      0           16358
    1102071001      JV15      16-JUL-06 3609      0           19872
    1102071001      JV15      16-JUL-06 0      95      19872
    1102071001      JV16      16-JUL-06 0      3608      16264
    1102071001      JV19      17-JUL-06      17000 0           -6668
    1102071001      JV19      17-JUL-06 0           22932      -6668
    1102071001      JV2      05-JUL-06      84000      0           18213
    1102071001      JV2      05-JUL-06 0           59119      18213
    1102071001      JV20      17-JUL-06 0           13000      5213
    1102071001      JV21      17-JUL-06 0      4000      1213
    1102071001      JV4      05-JUL-06      28134      0           -31786.57
    1102071001      JV4      05-JUL-06 0           61133.57      -31786.57
    1102071001      JV5      05-JUL-06 0      2970      -34756.57
    1102071001      JV7      05-JUL-06 5500      0           -29256.57
    1102071001      JV8      09-JUL-06 12500      0           -39147.57
    1102071001      JV8      09-JUL-06 0           22391      -39147.57
    1102071001      JV9      12-JUL-06 6740      0           -45107.57
    1102071001      JV9      12-JUL-06 0           12700      -45107.57

  • Sum values to display total (running total)

    I apologize for posting such a rudimentary question but I haven't been able to find an answer by searching the forum.
    Basically, I have several sensor inputs that are all factored into an equation that yeilds heat output (btu/hour). I need to take this value, which I have iterating once every second, and add it to itself every time it increments. In other words, say the first value is 10 (btus), the next second the value is 16, the code calculates and displays a value of 26 on the front panel and waits for the next second (or whatever iteration I choose) at which time it will add the new value to the running total.
    Thanks for your input
    Jake 
    Solved!
    Go to Solution.

    The Loopback function (<--) is basically a miniature shift register.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • 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

  • How to do running totals in a query

    Hi Guys, I have following data sample and desired output and I need a running total or subtotals on each row for two quntity fields on same row.
    Current data:
    ID - ---Day----- Qty1 Qty2
    Abc 04/01/2009 100 50
    abc 04/02/2009 70 20
    def 04/01/2009 10 30...
    Desired outPut:
    ID - ---Day----- Qty1 Subtoal Qty1 Qty2 SubtotalQty2
    Abc 04/01/2009 100 100 50 50
    abc 04/02/2009 70 170 20 70
    def 04/01/2009 10 180 30 30

    Hi,
    There's one thing in your example, regarding the last line:
    def 04/01/2009 10 180 30 30I assumed you meant:
    def 04/01/2009 10 180 30 100 <<== running total should be 100Am I correct?
    Then try:
    SQL> with t as (
      2  select  'Abc' col1, to_date('04/01/2009', 'dd/mm/yyyy') col2, 100 col3, 50 col4 from dual union all
      3  select'abc', to_date('04/01/2009', 'dd/mm/yyyy'), 70, 20 from dual union all
      4  select 'def', to_date('04/01/2009', 'dd/mm/yyyy'), 10, 30 from dual
      5  ) --Actual query starts here:
      6  select col1
      7  ,      col2
      8  ,      col3
      9  ,      sum(col3) over (order by rownum) rt_col3
    10  ,      col4
    11  ,      sum(col4) over (order by rownum) rt_col4
    12  from t;
    COL COL2             COL3    RT_COL3       COL4    RT_COL4
    Abc 04-01-2009        100        100         50         50
    abc 04-01-2009         70        170         20         70
    def 04-01-2009         10        180         30        100Edited by: hoek on Jun 24, 2009 5:19 PM added question

  • Running Totals, is there a method for this

    Hello, I am racking my brain out trying to figure out how to do a running total based on each succeding input by the user. It goes like this, if a person has more then x, then it does an if else statement based on the value inputted, else something else. The problem that Im having is trying to figure out how to keep the total in and add it to each successive input, and allowing the whole thing to be ended with a while ! =1.
    Any suggestions would be so greatly appreciated.
    Best Regards,
    MT

    I Given below the solution for whatever understand from the question given below.
    For example if you run
    C:>java Tot 121 150 you will get the following output.
    Total No of Inputs : 2
    The Input value1=121
    The Input value2=150
    Total = 271
    public class Tot{
         public static void main(String args[]){
              System.out.println("Total No of Inputs : "+args.length);
              int total = 0;
              for(int pos=0;pos<args.length;pos++){
                   System.out.println("The Input value"+(pos+1)+"="+args[pos]);
                   total = total + Integer.parseInt(args[pos]);
              System.out.println("Total = "+total);
    Darma

  • How do I put a running total in a Reports 6i Report?

    I need to write a report which shows a running total at the foot of each page. The report is a series of (potentially) multi-page sections each formatted like this:
    Page 1
    ======
    Tom £100
    Dick £150
    Harry £100
    Sub Total £350
    Page 2
    ======
    Peter £200
    Paul £50
    Mary £100
    Total £700
    Lines are of variable height, so I can't predict how many there'll be on a page.
    The help system just tells me to "use a summary field". Yeah, right. Can anybody give me some more detailed instructions?
    -- Chris Hunt

    Thanks for that.
    I didn't really express the problem as well as I might have done, as the Sub-Total needs to be the sum of all the items on the current page and on all preceeding pages. resetting on page just gives you the total for that page.
    I did find a way to do it. First you set up a summary field in the same group as the data lines, summing the amount and resetting on the parent group. This gives you a running total for each row:
    Page 1
    ======
    Tom £100 £100
    Dick £150 £250
    Harry £100 £350
    Page 2
    ======
    Peter £200 £550
    Paul £50 £600
    Mary £100 £700
    You don't actually output this summary field in the prinout (except when debugging :-) ). Now create a summary field at the foot of the page, or in the margin. Set its value to the Max() of the running total summary, resetting on page. That gives you the amount required, assuming all individual amounts are positive.
    If it's possible to have negative amounts, I expect that using Last() instead of Max() for the page summary would do the trick.

  • Running Total in the template

    Hi,
    I Have a requirement is there is running page total at the every page which gets updated for page wise in the Actuate report.That part i am not able to implement in the BIP ,if i place the running toatl code in footer it throws errors saying that variabels cant be used in the footer.
    How can i restrict the number of line in the report output and display the sum upto that part of records, and next diaplay the rest of records..
    Example :
    XML has : 1 to 75 values for the Amount paid on thatt day.
    when i generate the output...assume it occupies 3 pages .
    Running total : 1-25 records (total on that page)
    25-50 records (earlier page total +this page total)
    50-75 records (earlier two pages total +this page)
    Kindly let me know.
    Regards,
    Sahithi Surineni
    email : [email protected]
    If you have still queries,kindly give me a call.So that i can explain you more clearly.

    Hi,
    I am looking for the similar stuff :( nobody helps ?

  • Formatting Page Running Total - Need Urgent Help !!!

    Hi All,
    We need to format the page running total in European style and US style based on functional currency.
    Our current output is
    +1,200.00+
    Required output
    +1.200,00+
    <?xdoxslt:pat_format_number(12345, ‘##,##0.00’, $_XDOLOCALE)?>
    if $_XDOLOCALE = 'de-DE'
    Returns a number formatted with the specified pattern.
    For example:
    <?xdoxslt:pat_format_number(12345, ‘##,##0.00’, $_XDOLOCALE)?>
    returns
    12,345.00
    But the number 12345 above here is hardcoded but we need the number to be dynamic and it is the page running total.
    We are deriving the page running total in the following way:-
    <xdofo:inline-total
    display-condition="exceptlast" name="InvAmt"><xdofo:show-carry-forward name="InvAmt" format="99G999G999D00"/>
    </xdofo:inline-total
    Any Clues !!!
    Thanks...

    Got the solution and this is very important one !!!
    <xdofo:inline-total display-condition="exceptlast" name="InvAmt"><xdofo:show-carry-forward name="InvAmt" format="99G999G999D00" number-separators=",."/></xdofo:inline-total>
    <xdofo:inline-total display-condition="exceptfirst" name="InvAmt"><xdofo:show-brought-forward name="InvAmt" format="99G999G999D00" number-separators=",."/></xdofo:inline-total>

  • 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

  • Item Transaction History Report - Calculation for creating 'Running Total'

    Hello
    Using Oracle Discoverer, we have written a report that pulls back all Inventory Transactions (by item number). This report lists both transactions IN (e.g. receipts into the store) and OUT (e.g. issues out from the store).
    Our customer would like an additional column, to represent 'Running Total', to be added to the report. This column needs to capture the running 'On Hand Quantity' for the associated Item, as each transaction (both transactions IN and OUT of store) is displayed.
    For example, if the initial/first transaction for an item was a Receipt of 500, then this column (on the first line) should display 500. If the second transaction for the item was an issue of 15, then this column (on the second line) should display 485. If the third transaction was for an issue of 50, then this column (on the third line) should display 435. If the fourth transaction was for a receipt of 20, then this column (on the fourth line) should display 455 etc etc
    I'm not sure how I'd write a calculation to cater for this (within discoverer) - do you know if this is achievable? Any help would be much appreciated. This would be easy enough to do in Excel, but I'm a bit of a novice when it comes to discoverer(!)
    Many thanks
    Ross

    Hi,
    You can generally do this type of calculation using analytic functions. You would partition by the item number and order by the transaction date in the analytic function. You can use SUM function (with an order by) to get a running total of a column in the report. You can SUM a calculation containing a CASE statement which changes the OUT transactions to a negative number. The SUM function will start at zero, so you then can use FIRST_VALUE function to get the first value for the item which you could then add to the totals.
    Rod West

  • Showing  running totals on AR statatement Report

    Hi All I need assistance in populating the Running totals on AR statement Report  , I am trying to calculate the running total on the RDF using the (sum Over Partition ) and Not on the RTF template please assist .
    here is my query below :
    select customers.customer_name,
      detail.customer_id,
      detail.customer_site_use_id,
    :CP_ACC_NAME,
    :CP_ACC_NUM,
    :CP_BRNCH_NAME,
    :CP_COL_EMAIL,
    :CP_COL_PHONE,
    :CP_BRANCH_NR,
    decode(  (select meaning
    from ar_lookups
    where lookup_type = 'INV/CM/ADJ' and lookup_code =  detail.class), 'Payment', apply_date, trx.trx_date)  TRX_DATE,
    trx.INVOICE_CURRENCY_CODE,
    trx.INVOICE_CURRENCY_CODE INVOICE_CURRENCY_CODE_BAL,
    NVL(trx.term_due_date,trx.TRX_DATE)  term_due_date,
    detail.customer_id cst_id,
      detail.customer_site_use_id cst_site_id,
      detail.customer_trx_id,
      detail.trx_number,
       (select meaning
    from ar_lookups
    where lookup_type = 'INV/CM/ADJ' and lookup_code =  detail.class) class,
      detail.amount_full_original,
      detail.end_bal * -1 , (detail.end_bal + detail.amount_full_original)* -1  closing_balance ,
    detail.amount_full_original -  detail.the_order * -1  closing_bal,
      (detail.amount_full_original - detail.running_total) running_total ,
      detail.running_tot ,
      customers.customer_name address1,
      customers.address1 address2,
      customers.address2 address3,
      customers.address3 address4,
      customers.city||' '||customers.state address5,
      customers.country||' '||customers.postal_code address6,
      addr.address1 rm_address1,
      addr.address2 rm_address2,
      addr.address3 rm_address3,
      addr.address4 rm_address4,
      addr.address5 rm_address4,
       :p_as_of_date_from date_from,
       to_char(to_date(:p_as_of_date_to,'DD-MON-YYYY'),'DD-Mon-YYYY') date_to,
      addr.org_id rm_org_id,
       rtrim(to_char(sysdate,'DD')||' '||to_char(sysdate,'Month'))||' '||to_char(sysdate, 'YYYY') curr_date
    from (select customer_id, CUSTOMER_SITE_USE_ID, trx.CUSTOMER_TRX_ID,trx.TRX_NUMBER, null apply_date,ps.class,ps.AMOUNT_DUE_ORIGINAL amount_full_original, the_trx.end_bal,the_trx.running_total , the_trx.running_tot , 1 the_order
    select customer_trx_id, sum(acctd_end_bal) end_bal  , running_total  ,  running_tot
    SELECT ps.customer_trx_id ,
       sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
       NULL,to_date(:p_as_of_date_from))
      * ps.amount_due_remaining) start_bal,
       sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
       NULL,to_date(:p_as_of_date_to))
      * ps.amount_due_remaining) end_bal,
       sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
       NULL,to_date(:p_as_of_date_from))
      * ps.acctd_amount_due_remaining) acctd_start_bal,
       sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
       NULL,to_date(:p_as_of_date_to))
      * ps.acctd_amount_due_remaining) acctd_end_bal ,
       (sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
       NULL,to_date(:p_as_of_date_from))
      * ps.amount_due_remaining) + sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
       NULL,to_date(:p_as_of_date_to))
      * ps.acctd_amount_due_remaining) ) running_total ,  
       sum((sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
       NULL,to_date(:p_as_of_date_from))
      * ps.amount_due_remaining) + sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
       NULL,to_date(:p_as_of_date_to))
      * ps.acctd_amount_due_remaining) )) over (partition by ps.customer_trx_id  order by ps.customer_trx_id)running_tot
       FROM ar_payment_schedules_all ps
       WHERE ps.payment_schedule_id+0 > 0
       --JF2 AND ps.gl_date_closed >= to_date(:p_as_of_date_from)
       AND  ps.class IN ( 'CB', 'CM','DEP','DM','GUAR','INV')
       AND  ps.gl_date  <= to_date(:p_as_of_date_to)
       and org_id = nvl(:P_ORG_ID,org_id)--1246
       --and customer_id = :p_customer_id --1075
       --and CUSTOMER_SITE_USE_ID = :p_customer_site_id --1066
       --and customer_trx_id = 66291
       --'|| l_ps_org_where ||'
       GROUP BY ps.customer_trx_id ,ps.acctd_amount_due_remaining , ps.gl_date,ps.gl_date_closed ,ps.class , rownum 
      ps.customer_trx_id ,
       sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
      ra.gl_date,to_date(:p_as_of_date_from))
      * ( ra.amount_applied  + NVL(ra.earned_discount_taken,0)
       + NVL(ra.unearned_discount_taken,0))) start_bal,
       sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
      ra.gl_date,to_date(:p_as_of_date_to))
      * ( ra.amount_applied  + NVL(ra.earned_discount_taken,0)
       + NVL(ra.unearned_discount_taken

    Hi
    Yes i would like more help as i have never used group by roll up before
    SELECT p.employee_number,
    p.full_name employee_name,
    DECODE (p.sex, 'M', 'Male', 'F', 'Female') gender,
    (DECODE (p.per_information4,
    '01', 'Indian',
    '02', 'African',
    '03', 'Coloured',
    '04', 'White')) race,
    p.original_date_of_hire,
    a.effective_start_date startdate_current_position,
    RTRIM (SUBSTR (ps.NAME, 1, INSTR (ps.NAME, ';')), ';') current_position,
    ho.NAME current_organization,
    xx_return_company_name(a.person_id, a.effective_start_date) current_company,
    RTRIM (SUBSTR (ps1.NAME, 1, INSTR (ps1.NAME, ';')),';') previous_position,
    ho1.NAME previous_organization,
    xx_return_company_name(a1.person_id, a1.effective_start_date) previous_company,
    a1.effective_start_date startdate_prev_position
    FROM per_assignments_v2 a,
    per_assignments_v2 a1,
    per_all_people_f p,
    per_all_positions ps,
    per_all_positions ps1,
    hr_all_organization_units_tl ho,
    hr_all_organization_units_tl ho1
    WHERE a1.person_id = a.person_id
    AND NVL (a1.position_id, 9) <> a.position_id
    AND a1.effective_end_date = a.effective_start_date - 1
    AND p.person_id = a.person_id
    and ho.ORGANIZATION_ID=ps.ORGANIZATION_ID
    and ho1.ORGANIZATION_ID=a1.ORGANIZATION_ID
    AND a.effective_start_date BETWEEN p.effective_start_date AND p.effective_end_date
    AND a.position_id = ps.position_id
    and p.EMPLOYEE_NUMBER not in ('1','2','3')
    AND a1.position_id = ps1.position_id(+)
    order by p.full_name

Maybe you are looking for

  • Scanner Presets - Adobe Acrobat 9 Pro

    I removed a Canon CanoScan LiDE 60 from my Vista computer, drivers and all. The scanner continues to display in the Configure Presets Scanner Selection drop-down list. I have been unable to remove the uninstalled scanner from the list. Any help would

  • How do I return playback to the main stage timeline from a symbol?

    In trying to learn Edge, is there a way to return playback (play from) once an animation is complete within a symbol? For instance, I have the main timeline that shows a symbol animation on creationcomplete, but when the animation is finished in the

  • Disappearing icons...

    My App Store disappeared from my home screen. How can I get it back? I've tried restoring the home screen but that didn't do it...

  • Identification of a daq board

    Hello all, in a try to give the user some informations on the board included in a test system I tried using DAQmxGetDeviceAttribute to retrieve product and serial numbers, but got strange results! On a brand new PCIe-6320, the product number retrieve

  • Detecting a mouse click on any (all) child components...

    Hey All, I am writing a number of compound GUI elements that i want to make focusable when you click any part of them. (i.e. a JTextArea inside a JScrollPane, coupled to a JTextField to provide input to the JTextArea). Is there an easy way to detect