JavaScript for the sum of a column cells

Hi all -

I have a table in expansion (lines can be added) and I am using the line of the column footer to calculate the average of the cells which do not have the value 0.

Form Calc is usually great, but in this case, I need to divide the sum by the number of cells that are not zero and I don't know how to do this via form Calc.

Successfully used javascript to identify the total number of occurrences and identify the number of instances that are zero, then the part of the denominator of the equation is fine. (Number of cases - number of zeros = denominator.)

Now, it's just the numerator. There must be a loop, right?

Is called table: table1

Line is called: data

cell is called: rated

Any thoughts? Or more effective methods? Thank you very much.

B

Hello

a solution in FormCalc could look this way:

form1.#subform[0].table1.footer.sum::calculate - (FormCalc, client)
var c = 0
var s = 0
for i = 0 upto (_data.count - 1) do
  if (data[i].eValue gt 0) then
  c = Sum(c, 1)
  s = Sum(s, data[i].eValue)
  endif
endfor

if (s gt 0 and c gt 0) then
  $ = Round(s / c)
else
  $ = 0
endif

Put this scriot in the calculate of the cell of the footer line event.

Tags: Adobe LiveCycle

Similar Questions

  • A simple query to write for the SUM of a column

    Hello

    I have a Quantity column. I want his total.
    For a PURCHASE, I would like to add the value in the column Qunatity.
    For a COPY, I want to subtract the value in the column Qunatity.
    So overall, the sum of the column should give me total buy less total sells.

    Any help is welcome.
    Thank you.

    Published by: TechVortex on August 11, 2011 11:49

    Like this?

    SQL> ed
    Wrote file afiedt.buf
    
      1  with sample_data as
      2  (
      3  select 100 quantity, 'B' flag from dual union all
      4  select 200, 'B' from dual union all
      5  select 100, 'S' from dual union all
      6  select 500, 'B' from dual union all
      7  select 200, 'S' from dual
      8  )
      9  SELECT SUM(quantity),
     10         SUM(DECODE(flag, 'B', quantity,
     11                          'S', -quantity)) absolute_sum
     12* FROM   sample_data
    SQL> /
    
    SUM(QUANTITY) ABSOLUTE_SUM
    ------------- ------------
             1100          500
    
  • SQL for the sum of a column while avoiding the repetition of values

    Dear all
    I have this table called Loans_installments that contains the client's loan payments.

    sample data:
    the client_id loan_no inst_mat_date inst_seq original_inst_amt int_amt currency management
    110 2 222 100 1/1/2013 1 0 50
    110 2 222 100 1/2/2013 2 0 52
    110 2 222 100 1/3/2013 3 0 54
    110 2 222 100 1/4/2013 4 500 90
    110 2 222 100 1/5/2013 5 0 50
    110 2 222 100 1/6/2013 6 0 51
    110 2 222 100 7/1/2013 7 0 50
    110 2 222 100 1/8/2013 8 600 105
    110 2 222 100 1/9/2013 9 0 50
    110 2 222 10 100 1/10 / 2013 0 54
    110 2 222 100 1/11 / 2013 11 0 50
    110 2 222 100 1/12 / 2013 12 700 120



    now what I want to do the sum of int_amt field based on original_inst_amt value (0 or a value) and put the result on the int_amt who has an orig_inst_amt value <>0.

    the result should be like this:


    the client_id loan_no inst_mat_date inst_seq original_inst_amt int_amt currency management
    110 2 222 100 1/1/2013 1 0 0
    110 2 222 100 1/2/2013 2 0 0
    110 2 222 100 1/3/2013 3 0 0
    110 2 222 100 1/4/2013 4 500 246
    110 2 222 100 1/5/2013 5 0 0
    110 2 222 100 1/6/2013 6 0 0
    110 2 222 100 7/1/2013 7 0 0
    110 2 222 100 1/8/2013 8 600 256
    110 2 222 100 1/9/2013 9 0 0
    110 2 222 100 1/10 / 2013 10 0 0
    110 2 222 100 1/11 / 2013-11 0 0
    110 2 222 100 1/12 / 2013 12 700 274


    any help please.

    With the help of the clause type

    SQL> with t
      2  as
      3  (
      4  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/1/2013','mm/dd/yyyy') inst_mat_date, 1  inst_seq, 0   original_inst_amt, 50 int_amt from dual
      5  union all
      6  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/2/2013','mm/dd/yyyy') inst_mat_date, 2  inst_seq, 0   original_inst_amt, 52 int_amt from dual
      7  union all
      8  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/3/2013','mm/dd/yyyy') inst_mat_date, 3  inst_seq, 0   original_inst_amt, 54 int_amt from dual
      9  union all
     10  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/4/2013','mm/dd/yyyy') inst_mat_date, 4  inst_seq, 500 original_inst_amt, 90 int_amt from dual
     11  union all
     12  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/5/2013','mm/dd/yyyy') inst_mat_date, 5  inst_seq, 0   original_inst_amt, 50 int_amt from dual
     13  union all
     14  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/6/2013','mm/dd/yyyy') inst_mat_date, 6  inst_seq, 0   original_inst_amt, 51 int_amt from dual
     15  union all
     16  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/7/2013','mm/dd/yyyy') inst_mat_date, 7  inst_seq, 0   original_inst_amt, 50 int_amt from dual
     17  union all
     18  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/8/2013','mm/dd/yyyy') inst_mat_date, 8  inst_seq, 600 original_inst_amt, 105 int_amt from dual
     19  union all
     20  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/9/2013','mm/dd/yyyy') inst_mat_date, 9  inst_seq, 0   original_inst_amt, 50 int_amt from dual
     21  union all
     22  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/10/201','mm/dd/yyyy') inst_mat_date, 10 inst_seq, 0   original_inst_amt, 54 int_amt from dual
     23  union all
     24  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/11/201','mm/dd/yyyy') inst_mat_date, 11 inst_seq, 0   original_inst_amt, 50 int_amt from dual
     25  union all
     26  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/12/201','mm/dd/yyyy') inst_mat_date, 12 inst_seq, 700 original_inst_amt, 120 int_amt from dual
     27  )
     28  select branch
     29       , currency
     30       , client_id
     31       , loan_no
     32       , inst_mat_date
     33       , inst_seq
     34       , original_inst_amt
     35       , decode(original_inst_amt, 0, 0, sum(int_amt) over(partition by cnt)) int_amt
     36    from (
     37            select branch
     38                 , currency
     39                 , client_id
     40                 , loan_no
     41                 , inst_mat_date
     42                 , inst_seq
     43                 , original_inst_amt
     44                 , int_amt
     45                 , cnt
     46              from t
     47             model
     48             dimension by
     49             (
     50                inst_seq
     51             )
     52             measures
     53             (
     54                branch, currency, client_id, loan_no, inst_mat_date, original_inst_amt, int_amt, 1 cnt
     55             )
     56             rules
     57             (
     58                 cnt[any] = case
     59                                   when original_inst_amt[cv()-1] > 0 then
     60                                      cnt[cv()-1] + 1
     61                                   else
     62                                      nvl(cnt[cv()-1], cnt[cv()])
     63                               end
     64             )
     65         )
     66  /
    
        BRANCH   CURRENCY  CLIENT_ID    LOAN_NO INST_MAT_   INST_SEQ ORIGINAL_INST_AMT    INT_AMT
    ---------- ---------- ---------- ---------- --------- ---------- ----------------- ----------
           110          2        222        100 01-JAN-13          1                 0          0
           110          2        222        100 02-JAN-13          2                 0          0
           110          2        222        100 03-JAN-13          3                 0          0
           110          2        222        100 04-JAN-13          4               500        246
           110          2        222        100 05-JAN-13          5                 0          0
           110          2        222        100 06-JAN-13          6                 0          0
           110          2        222        100 08-JAN-13          8               600        256
           110          2        222        100 07-JAN-13          7                 0          0
           110          2        222        100 09-JAN-13          9                 0          0
           110          2        222        100 11-JAN-01         11                 0          0
           110          2        222        100 10-JAN-01         10                 0          0
           110          2        222        100 12-JAN-01         12               700        274
    
    12 rows selected.
    
    SQL>
    
  • Calculation of the sum of a column on a XML editor RTF with NULL values

    Hello

    I have a problem to get the sum of a column in XML editor RTF, if one of the lines has a null value.

    say, I have 4 columns and values

    CASES1:
    NULL, NULL, 4, NULL
    Sum, I expect is: 4

    CASE2:
    NULL, NULL, NULL, NULL
    I'm waiting for is a null

    Is there a way to do this?

    Thank you
    Anita

    Try this

    AMT's column

  • Is there an alternative way to compute the sum of a column without accessor view

    Hi Experts,

    JDev 12 c,

    I have a column A and I'm total calculation of column A with the same VO as a view accessor. And calculating as below

    EmployeeViewAccessor.sum ("ColumnA").

    But this way, it loads the VO 2 times as it loads the accessor aswell.

    So is there an alternative way to calculate the sum of a column.

    Thank you

    Roy

    Use the analytical function, please see below Ex

    http://docs.Oracle.com/CD/B19306_01/server.102/b14200/functions163.htm

  • "Adobe than Photoshop Lightroom 5.4 cannot be installed to this disk. An error has occurred all in assessing the JavaScript for the package. »

    Hello

    I get this error when trying to install / update LR 5.3 5.4:

    "Adobe than Photoshop Lightroom 5.2 cannot be installed to this disk. An error has occurred all in assessing the JavaScript for the package. »


    I hope that there is someone who can help me here.

    See you soon

    Re: Lightroom 5.2 installation fails - WARNING Javascript

  • How to get the last row and the sum of all columns in a query

    Hello

    is there a way to get the last record for a column and the sum of all the Archives to another column in the same query.

    Best regards

    You must set your needs correctly volunteers to help here...

    Your data are not good enough to bring you a precise solution. Purpose, you do not have a column, which draws a distinction between the first and the last entry.

    The solution becomes easy based on your design.

    I introduced a grouping called 'id' column and a time column called 'time_of_insert' (only this way you can say with confidence that you can differentiate between the first and last (also a foolproof solution) - you can possibly use sequence (instead of date but if you say that you can insert two lines at the same time) ((and then likely sequence would be a better choice to differentiate instead of a timestamp field) etc...)

    With your sample data, something like this can be done to get the desired results.

    -----------------------------------------------------------------------------------------------------------------------

    WITH dataset AS

    (SELECT 1 id, 10 used, 8 remain, systimestamp + 1/24 time_of_insert FROM DUAL

    UNION ALL

    SELECT the 1 id, 1, 7, systimestamp + 2/24 FROM DUAL

    UNION ALL

    SELECT the id 1, 2, 5, systimestamp + 3/24 FROM DUAL

    UNION ALL

    SELECT 1 id, 1, 0, systimestamp + 4/24 FROM DUAL

    UNION ALL

    SELECT 1 id, 0, 0, systimestamp + 5/24 FROM DUAL

    UNION ALL

    SELECT the 1 id, 1, 4, systimestamp + 6/24 FROM DUAL)

    SELECT *.

    (SELECT SUM (used) ON sum_all)

    FIRST_VALUE (stay)

    COURSES (PARTITION BY id ORDER BY time_of_insert DESC)

    last_row

    Of THE dataset)

    WHERE ROWNUM = 1;

    Output:

    ------------------------

    SUM_ALL LAST_ROW

    ------------------------------

    15                  4

    See you soon,.

    Manik.

  • for the sum

    Hello

    I'm having a problem trying to the sum of 200 items I've read in a loop for, for then to get the average value. the value that I'm reading is a temeperature, but is oscilates and I need to get an average value for the pid controller don't get 'confused' by the waves.

    can someone help me please?

    Try something like that. I can't test it here, because I don't have the equipment.

  • How Oracle called the hidden for the function-based index columns?


    I came across an interesting problem today.  Statistics object for a schema that have been created on the basis of data X have been imported into a 'identical' to the database schema Y.

    The problem is that, on the basis of data X a group of hidden columns associated with index based service (FBIs) were named SYS_NC00182$ to SYS_NC00191$ and on the basis of data Y the same hidden columns were named SYS_NC00183$ to SYS_NC00192$!  The consequence was that statistical column for an FBI data base X have been used for a totally different FBI on the database Y.

    Now, of course, if this was g 11 or 12 c I could just create virtual columns and those of the index.  In this way the names of the columns would be compatible on databases.  However, it is a 10g database, and I do not have this option.

    I am curious to understand how Oracle generates these hidden column names.  I'm also curious if, in 10g, there is a way to identify the name of a column hidden for an FBI that doesn't involve a statement explain plan running on a query that uses all the expressions of the FBI for the table.

    The names of $ SYS_NCnnnnn are based on the internal column id - what is loosely based on the order of creation of the FBI. If you delete a column the column internal ids (after this column), which means the names for the SYS_NCnnnnn$ the change.  An opportunity to explain your results is that a (real) column on the X data table fell, but the column still exists on the database Y.

    If you want to get the link between the current internal name and expression, then you can start with dba_ind_expressions - and create a customized version of the view - e.g @.

    Select c.intcol #, c.name, io.name, idx.name, bo.name, base.name, c.default$, ic.pos #.

    of sys.col$ c, sys.obj$ idx, basis of sys.obj$, sys.icol$ ic.

    sys. User$ io, sys.user$ bo, sys.ind$ I

    where bitand(ic.spare1,1) = 1 / * expression * /.

    and (bitand (students, 1024) = 0) / * not bmji * /.

    and ic.bo # c.obj = #.

    and ic.intcol # c.intcol = #.

    and ic.bo # base.obj = #.

    and io.user # idx.owner = #.

    and bo.user # base.owner = #.

    and ic.obj # idx.obj = #.

    and idx.obj # i.obj = #.

    and however # (1, 2, 3, 4, 6, 7, 9)

    /

    The first two columns in the select ones that I added to the initial view definition.

    Concerning

    Jonathan Lewis

  • JavaScript for the calculation of tax on income at several levels

    Hello world

    I am writing a script to custom calculation for the calculation of tax on income at several levels:

    1. the income up to $40,000 (20%)

    2. revenue between $40 001 and $60,000 (30%)

    3. revenue between $60 001 and $100,000 (35%)

    4 income more than $100 001 (40%)

    If the income is $ 80,000, tax calculation would be:

    Total tax = (40 000 * 20%) + (20 000 * 30%) + (20 000 * 35%)

    I managed to get the correct calculation for #1 but I'm having a difficult time for the rest. Here is my script to the point #1

    var value = Number (this.getField("Income").value);

    if(nValue<40001) {event.value = math.max (0, nValue * 0.20);}

    }

    else {event.value = 40000 * 0.20;}

    }

    Also, when I tried to change the amounts in the income, the tax has not changed.

    Help, please.

    Thanks in advance.

    I think that you need a script like:

    Event.Value = 0;
    var value = this.getField("Income").value;

    If (value > 0 & nValue)< 40000)="">
    20% of the income;
    NValue = Event.Value *. 2;
    }
    If (value > = 40000 & nValue)< 60000)="">
    30% of income plus 40 000 + 20% of 40000;
    Event.Value = (.3 * (nValue - 40000)) + (.2 * 40000);
    }
    If (value > = 60000 & nValue)< 100000)="">
    amount of 35% more than 60 000 + 30% 20 000 + 20% of the 40,000
    Event.Value = (.35 *(nValue-60000) + (.3 * 20000) + (.2 * 40000);)
    }
    If (value > = 100000) {}
    40% amount plus 100 000 + 35% of 40 000 + 30% of 20000, 20% of the 40,000
    Event.Value = (.4 * (nValue - 100000)) + (.35 * 40000) + (.3 * 20000) + (.2 * 40000);
    }

    To obtain your code, did you check the JavaScript console?

    Understand how interpreted languages handle errors?

  • Application of distribution for the bucket a bound column

    Hello

    I need connect chain for the table data and assign a number of unique to those bucket.
    Here is the example (Col1 and Col2 are the table columns and bucket is aquery column):

    | Col1 | Col2. Bucket |
    | A1 | B1 | 1.
    | A1 | B2 | 1.
    | A2 | B2 | 1.
    | A3 | B3 | 2.
    | A4 | B3 | 2.
    | A4 | B4 | 2.
    | A5 | B2 | 1.

    In the above example you can see that there is a string A1-> B2-> A2 and A5, so they have the same number of bucket 1. It is also interesting to note that all lines containing A1 in Col1 will reside in the same compartment, and therefore A1-> B1 is assigned also bucket 1.
    Another example is a String->->-> B4 A4 B3 A3 and therefore have bucket number 2.

    I tried the hierarchical queries, but wasn't able to get the desired result.

    Can anyone suggest an approach or a query?

    Thanks in advance.

    Rgds,
    AKS.

    Hi, Aks,

    We don't know what you want.
    Do you want to assign the bucket such that all rows that have the same value of col1 or col2 the same value receive the same number of bucket?

    Maybe you want something like this:

    WITH     got_relatives     AS
    (
         SELECT     col1
         ,     CONNECT_BY_ROOT col2     AS relative
         FROM     table_x
         CONNECT BY NOCYCLE     col1     = PRIOR col1
                 OR          col2     = PRIOR col2
    )
    ,     got_bucket     AS
    (
         SELECT       col1
         ,       DENSE_RANK () OVER ( ORDER BY  MIN (relative)
                                   ) AS bucket
         FROM      got_relatives
         GROUP BY  col1
    )
    SELECT       x.*
    ,       b.bucket
    FROM       table_x     x
    JOIN       got_bucket     b  ON     x.col1     = b.col1
    ;
    

    I hope that answers your question.
    If not, post CREATE TABLE and INSERT to your sample data and results statements you like from these data (otherwise what you've posted already).
    Explain, using specific examples, how you get these results from these data.

    Always tell what version of Oracle you are using. This is particularly important with CONNECT BY queries, because each version since Oracle 7 has had major improvements in this area.

    You will answer sooner if you always include this information whenever you have a question.

  • The sum of a column with 2 values using Forms 6i

    Hello world
    I have 2 blocks, a main block and the other is
    my block of retail and my block of retail element is a list item
    When I have 2 options to choose, we're for described video and the
    Another is for delay.
    My question is:
    How can I add an item in my form where I will summarize the
    amount of A and L is inserted on this column?

    I forgot about it. DECODE cannot be used in SQL. This time I tried the solution myself in Forms 6i, so I know it works. Set the formulas

    InStr(:Item,'A')

    This returns 1 if the value is A, 0 otherwise. Ditto for the L value of course.

  • the sum of a column where date column is converted in year + 1

    Hello

    I want the sum, said the column of taAmt where he is not null and the column fromPeriod is converted to the format of the year and has 1 year. This syntax does not work, can anyone help?

    <? sum (taAmt [.! = "and fromPeriod ('YYYY') + 1])? >

    Assigning :) Points If you wish

  • query for the sum error

    Hello

    SELECT SUM (coalesce (cast (b.co1000000351 AS INT), 0)) + sum (coalesce (CAST (b.co1000000352 as INT), 0)) + sum (coalesce (CAST (b.co1000000353 as INT), 0)) as a result
    of B2601 b, T2601 t
    where b.C1 = t.C1 AND t.C1000000161 = 'PR00003525614'
    B.c1 group


    In the above query, I get the result successfully:

    Result
    ------
    100
    300
    400

    I want to do is the sum of the sum of the values from the query and result either 800 above = 100 + 300 + 400

    I tried, but my request is in error:

    SELECT SUM)
    SELECT SUM (coalesce (cast (b.co1000000351 AS INT), 0)) + sum (coalesce (CAST (b.co1000000352 as INT), 0)) + sum (coalesce (CAST (b.co1000000353 as INT), 0)) as a result
    of B2601 b, T2601 t
    where b.C1 = t.C1 AND t.C1000000161 = 'PR00003525614'
    B.c1 group
    )
    Double;            -In error


    Any help please.

    Remove the GROUP BY and try

    Select sum (coalesce (cast (b.co1000000351 as int), 0)) +.

    sum (coalesce (cast (b.co1000000352 as int), 0)) +.

    sum (coalesce (cast (b.co1000000353 as int), 0)) as a result

    of b2601 b

    t2601 t

    where b.c1 = t.c1

    and t.c1000000161 = 'PR00003525614. '

  • The execution of Javascript for the onchange event of Rich text editor field

    Hello

    I have a piece of javascripts that warns users when they try to move away from a page with unsaved changes (if they change all fields in a form). The code works for all types of fields except for rich text editors.

    I think that the reason might be (not 100% sure) which is the form element when users type in their changes is nested inside an iframe html document, and my jQuery onchange event trigger nested inside an html document changes.

    Dynamic measurements also do not work if you create a simple rich text box and write JavaScript codes in onchange events fire.

    Would be grateful if anyone can suggest a way to make my Rich Text Editor work fields onchange events.

    I use Apex 4.2.2 theme 26.

    The field is a Rich Text Editor to type CKEditor3, Toolbar = intermediate.

    Hello

    This might help

    Re: Counter of characters for a rich text editor.

    Kind regards
    Jari

Maybe you are looking for