Sum function on Sql display on a Jtable

Hi,
I'm trying to add up the values of a column on a Jtable and somehow display the Total. I have been trying to do the query by using a join on sql. Here is the code:
private void getTotal()                         {             Connection con = getConnection();             try{                 String sql = "SELECT Item.Item_price" +                         "FROM Item INNER JOIN [Order] ON Item.Item_ID = Order.Item_ID" +                         "SUM(Item_price) Where Order.Table_number = " + Integer.parseInt(tableNumber)+";";                 PreparedStatement pStmt = con.prepareStatement( sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE );                 ResultSet rs = pStmt.executeQuery( );                 DefaultTableModel tableModel = new DefaultTableModel();                 tableModel.addColumn("Item_price");                 Object [] row = { rs.getObject(1)};                 tableModel.addRow(row);                 con.close();                 jTable1.setModel(tableModel);                                             }                   catch(Exception e)     { System.out.println(e);     }         }
Does anyone know a good method of doing this?
Thanks.

Dear Antony Gitonga  
It's not Table sum.
Plaese see the where condition, it will take only the current father and sum the quantity.
Plaese save the query in query manager and assign it in formated search and try.
select sum(T1.U_Base_Qty) From OITT T0,ITT1 T1
where
T0.code=T1.father and
T0.code = $[OITT.Code]
Regards,
Thanga Raj.K
Edited by: Thanga Raj K on Jun 1, 2009 12:15 PM
Edited by: Thanga Raj K on Jun 1, 2009 12:18 PM

Similar Messages

  • SUM function issue

    Hi everyone,
    I have a problem with SUM function in SQL query on Oracle 11g database. Maybe you will be able to help me.
    Problem:
    I want to shows summary costs for shipments separately for each service provider and for each month they did the shipments.
    Data is stored in SHIPMENT AND SHIPMENT_COST table as shown below. The problem is that summary function I use sums base costs (marked as B in SHIPMENT_COST table) for each accessorial cost (marked as A in SHIPMENT_COST table). In example for shipment 10005031 we have 4 accessorial costs so it shows 6120 in BASE_COST column. I tried to use distinct in summary but then we have a problem with shipment id 201307133713_0383 which has 3 base costs equal to 221.54 so with distinct it will show 221.54 instead of 221.54x3.
    SHIPMENT table:
    START_TIME               SHIPMENT_GID               SERVPROV_GID
    2013-06-25                    10005031                         T222176
    2013-06-15                    201307133713_0383          T76180
    SHIPMENT_COST table:
    SHIPMENT_GID                        COST                                       COST_TYPE
    10005031                                 1530                                        B
    10005031                                  30.6                                        A
    10005031                                  120                                         A
    10005031                                  400                                         A
    10005031                                  100                                         A
    201307133713_0383                   221.54                                    B
    201307133713_0383                   221.54                                    B
    201307133713_0383                   221.54                                    B
    RESULT table:
    SHIPMENT_START_DATE
    SERVPROV
    BASE_COST
    CLAIM_COST
    06/2013
    T76180
    664.62
    null
    06/2013
    T222176
    6120
    650.6
    Query:
    SELECT DISTINCT TO_CHAR(SH.START_TIME,'MM/YYYY') AS SHIPMENT_START_DATE,
            SH.SERVPROV_GID AS SERVPROV,
            SUM(SHCOST.COST) AS BASE_COST,
            SUM(SHCOST_CLAIM.COST) AS CLAIM_COST
    FROM    SHIPMENT SH,
            SHIPMENT SHC
            LEFT OUTER JOIN SHIPMENT_COST SHCOST ON (SHC.SHIPMENT_GID = SHCOST.SHIPMENT_GID AND SHCOST.COST_TYPE = 'B'),
            SHIPMENT SHC_CLAIM
            LEFT OUTER JOIN SHIPMENT_COST SHCOST_CLAIM ON (SHC_CLAIM.SHIPMENT_GID = SHCOST_CLAIM.SHIPMENT_GID AND SHCOST_CLAIM.COST_TYPE = 'A')
    WHERE 1=1
            AND SHC.SHIPMENT_GID = SH.SHIPMENT_GID
            AND SHC_CLAIM.SHIPMENT_GID = SH.SHIPMENT_GID
            AND    SH.SHIPMENT_GID IN ('10005031','201307133713_0383')
            GROUP BY TO_CHAR(SH.START_TIME,'MM/YYYY'),
            SH.SERVPROV_GID
    Best Regards,
    Łukasz

    with SHIPMENT (START_TIME,SHIPMENT_GID,SERVPROV_GID) as
    select to_date('2013-06-25','yyyy-mm-dd'),'10005031','T222176' from dual union all
    select to_date('2013-06-15','yyyy-mm-dd'),'201307133713_0383','T76180' from dual
    SHIPMENT_COST(SHIPMENT_GID,COST,COST_TYPE)
    as
    select '10005031','1530','B' from dual union all
    select '10005031','30.6','A' from dual union all
    select '10005031','120','A' from dual union all
    select '10005031','400','A' from dual union all
    select '10005031','100','A' from dual union all
    select '201307133713_0383','221.54','B' from dual union all
    select '201307133713_0383','221.54','B' from dual union all
    select '201307133713_0383','221.54','B' from dual
    select *
      from (select to_char(t.START_TIME, 'mm/yyyy'),
                   t.SERVPROV_GID,
                   c.COST,
                   c.COST_TYPE
              from SHIPMENT t
              join SHIPMENT_COST c
                on t.SHIPMENT_GID = c.SHIPMENT_GID)
    pivot(sum(COST) for COST_TYPE in('A' CLAIM_COST,'B' BASE_COST))
    TO_CHAR(T.START_TIME,'MM/YYYY'
    SERVPROV_GID
    CLAIM_COST
    BASE_COST
    06/2013
    T76180
    664.62
    06/2013
    T222176
    650.6
    1530
    Ramin Hashimzade

  • Want to convert function in SQL Server 2000

    Hi ,
    i am writing this function in oracle.Could you please convert this function in SQL Server 2000 because i am new in this and dont know how to use decode function in sql.
    Please following is the code for oracle.
    CREATE OR REPLACE function fun ( localex varchar2,titlex varchar2)
    return number
    as  x number;
    begin
    select sum ( decode (count (username),max(prereq_count),1,0) ) x into x from
       SELECT
                       prereq_count,
                       username
                 FROM
                         table1
    group by     username ;
    return x;
    end fun;
    Regards
    Vishal

    Just take a look example below might give you idea :
    create or replace function f_makeAddress_tx (
    i_address_tx VARCHAR2,
    i_city_tx VARCHAR2,
    i_state_tx VARCHAR2,
    i_zip_tx VARCHAR2)
    return VARCHAR2
    is
    e_badZip EXCEPTION; u279E8
    pragma EXCEPTION_init(e_badZip,-20998); u279E9
    v_out_tx VARCHAR2(256);
    begin
    p_validateZip (i_zip_tx); u279E12
    v_out_tx:= i_address_tx||u2019, u2018|| u279E13
    i_city_tx ||u2019, u2018||
    i_state_tx ||u2019, u2018||
    i_zip_tx;
    return v_out_tx; u279E17
    exception
    when e_badZip then u279E19
    return i_zip_tx || u2018: Invalid zip code.u2019;
    end;
    Regards,
    Clint

  • Error when using SUM function in Excel template

    I am trying to use the XDO_METADATA to create a sum of a column from my XML data and I am getting the following error in the Template Viewer:
    [111412_104246459][][PROCEDURE] Log Level is changed to PROCEDURE
    [111412_104246553][oracle.xdo.common.xml.XSLTWrapper][ERROR] XSL error:
    Time: 0.125 sec.
    FO Formatting failed.
    <Line 317, Column 116>: XML-23029: (Error) FORG0001: invalid value for cast/constructor
    @Line 317 ==> <Cell Index="2" Style="R7C3" Field="XDO_?SUM_V_CR_MO_IDD1?"><xsl:value-of select="sum(.//G_CR_MST_D/V_CR_MO_IDD)"/>
    when I use:
    XDO_?SUM_V_CR_MO_IDD1?     <?sum(.//G_CR_MST_D/V_CR_MO_IDD)?>
    or
    [111412_104048508][][PROCEDURE] Log Level is changed to PROCEDURE
    [111412_104048554][oracle.xdo.common.xml.XSLTWrapper][ERROR] XSL error:
    Time: 0.078 sec.
    FO Formatting failed.
    <Line 317, Column 105>: XML-23029: (Error) FORG0001: invalid value for cast/constructor
    @Line 317 ==> <Cell Index="2" Style="R7C3" Field="XDO_?SUM_V_CR_MO_IDD1?"><xsl:value-of select="sum(.//V_CR_MO_IDD)"/>
    when I use:
    XDO_?SUM_V_CR_MO_IDD1?     <?sum(.//V_CR_MO_IDD)?>
    I believe the XSL to be correct because when I change it to a count it works and when I go into BI Publisher 11g and create the query in the data model and then create a summary from it, the summary is created.
    Can anyone help?

    I went back to basics and created reports (via EXCEL templates) like I was asking based on good old EMP and DEPT and I found exactly the same problems I was mentioning. I looked at the templates provided but they were not calculating totals, like me they were selecting them and then just displaying them on the page.
    Anyway, I have narrowed it down to the fact that when you do aggregates like sum(.//SAL) this works if you have a salary for every value. I did an outer join with DEPT so I did have empty rows and why I still experienced the problems.
    Basically XSL does not like adding (including using the sum function) values that effectively have nulls in them which is why I get the cast/constructor errors because it is trying to turn a NaN value to a number and does not (or cannot) do it.
    You need to either have a value in every row of your column (maybe possible by selecting nvl in your query) and make sure that you check the "create empty nodes" checkbox in the data model of BI Publisher.,
    the other solution is an xsl solution where you would have to make sure that you only added non null values and for that you would have to investigate xsl blogs.
    It is, by the way, why my count worked because it is just counting that the record exists it does not care what the element content is or isn't.
    Closing thread.

  • APEX, BI Publisher and SQL Query (PL/SQL Function returning SQL Query)..

    I don't know if I should be posting this in this Forum or the BI Publisher forum, so I am posting in BOTH forums..
    I love APEX, let me say that first.. And appreciate the support offered here by the group, but am running int a confusing issue when BI Publisher tries to build a report from the above type APEX report..
    Here is my dilemma:
    I have a number of reports that are part of a Oracle package. They return an SQL Query back to a reports region on a page. I am having to deal with the column names returned are col01, col02..
    The issue I have is, when building the Application Level query to download the XML sample from in building RTF layouts in Word, you can not use this code, you MUST use a standard SQL Select.
    I have taken the sql from the function returning sql, and copied into the application query, supplying the required data values for bind variables being used in the query.
    An XML file is produced, and I use this to build the RTF format file that I load back into APEX and try to use it for the PDF rendering of the report. I can view the output as a PDF in the Word add on, but when I try using it with the report, it is returning an empty PDF file.
    Can anyone tell me what error log files on the bi publisher side I can look at to see what error is happening?
    Thank you,
    Tony Miller
    UTMB/EHN
    Title changed, maybe SOMEONE has an idea on this??
    Message was edited by:
    Tony Miller

    Hi,
    1/ first check you are passing the bind variables and
    appropriate values in the call to your report - if
    the query returns no data then you get an empty page
    So if your query takes :P10_USERNAME variable then
    pass it to the report in the URL
    f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=YOUR_REP_QUERY_N
    AME:::P10_USERNAME:MYUSER
    2/ try to use the Default layout first to check your
    report query really returns the data when called
    3/ if you defined a header in your rtf template check
    there is no & (ampersand) - if using & in the header
    and preview the template from word it displays data
    OK, but if you use this template in the report query
    it fails to render the data (bug in Apex-> Bi
    Publisher integration maybe?)
    4/ If using the table in the rtf template check its
    width does not overflow the page margins - there is a
    problem with pdf export
    5/ check
    /oc4j/j2ee/home/application-deployments/xmlpserver/app
    lication.log forthe information on BI Publisher runs
    RadoIssue was in the APEX page having issues.. I recoded a new page and am able to generate BI Publisher based PDF files..
    Thank you,
    Tony Miller
    UTMB/EHN

  • On Submit process not firing -report (PL/SQL function returning SQL query)

    Can anyone suggest possible causes / solutions for the following problem?
    I have a report region that uses a PL/SQL function returning SQL query. The report allows the user to update multiple fields / rows and then click a button to submit the page which should run the On-Submit process to update the database. However the process does not run and I get a 'HTTP404 page cannot be found' error; and when I navigate back using the Back button I cannot then navigate to any other page in my application without getting the same error. The button was created by a wizard selecting the options to submit the page and redirect to a (same) page. The button does not actually have a redirect in its definition but the wizard created a branch to the same page which should work and the button has the text 'submit as SUBMIT' next to it so it appears to be set up correctly.
    I have recreated this page several times in my application and I cannot get the On-Submit process to run. However I have created a cut down version of the same page in the sample application on apex.oracle.com at http://apex.oracle.com/pls/otn/f?p=4550:1:179951678764332 and this works perfectly so I am at a loss to understand why it does not work in my application. I cannot post any part of the application itself but if anybody would like to check out page 30 of the sample application (Customer Update Test tab) updating the surnames only, using credentials ja, demo, demo this is pretty much what I have got in my application.
    Any ideas would be much appreciated?

    Thanks for the suggestions guys. I have now identified that the problem goes away when I remove the second table from my report query. The original report query retrieved data from two tables and the process was updating only one of the tables. I thought I had approached the task logically i.e. first get the report to display the records from the two tables, then get the process to update the first table and finally to modify the process further to update the second table.
    Can anyone point me to an example of multiple row updates on multiple tables using a PL/SQL function returning an SQL query?

  • How to correct XML Output in Cross Tab Template for sum function?

    I have designed a Cross Tab Template to summarize R12 Account Analysis data by Period by Party_name. The template is doing what I want it to do with the exception of amount. I have a function in the sum(accounted_net) field and it will only display 0.00 even though I know there are actual amount. Can someone help in looking at my template to see what I have done wrong?
    Here is the sum funciton.
    <?if:count(current-group()[CCID_SOURCE=$ABC])?><?sum(current-group()[CCID_SOURCE=$ABC]/ACCOUNTED_NET)?> <?end if?>
    CCID_SOURCE is an element I created in XML to concatnate CCID and Party_name for grouping. $ABC is a variable that I defined for "CCID_SOURCE" to check if there is null value for a specific ccid_party. If it's null, it won't do the sum function, otherwise it will sum the accounted_net for the period_name, party_name.
    Thank you for your help.
    Stacey

    Figured this out on our own

  • FORMAT function in SQL

    Can I use FORMAT function in SQL statement?
    If not, how to do it?
    Here is the SQL that I want to do.
       SELECT last_name, first_name, FORMAT(birth_date, 'mm/dd/yyyy') FROM customer

    Hi,
    To display the result as mm/dd/yyyy, you can use the code like below:
    DECLARE @d DATETIME = '10/01/2011';
    select FORMAT(@d,'d','en-US'  )
    To display the result as yyyymmdd, use CONVERT:
    DECLARE @d DATETIME = '10/01/2011'
    SELECT convert(varchar, @d, 112)
    Reference:
    http://www.sqlusa.com/bestpractices2005/centurydateformat/
    Thanks.
    Tracy Cai
    TechNet Community Support

  • Help with SUM function ??

    Hi,
    I am trying to build a SUM function into the following SELECT statement;
    SELECT   emp_code "EmployeeCode", trn_date "TransactionDate", project "ProjectCode",
    phase_code "PhaseCode", task_code "TaskCode", reg_hrs "RegularHoursAmt", rate_reg "RegularHoursRate", ot_hrs "OvertimeHoursAmt", rate_ot "OvertimeHoursRate"
    Currently when i do the extract to xls I manually compile the "RegularHoursAmt" and "RegularHoursRate" manually and it's quite a task. I'm sure it can be completed in teh SELECT but I'm not clear on how and it's been quite some time since my last foray into SQL. Any assistance appreciated.
    I need to sum "RegularHoursAmt" and "RegularHoursRate"
    per "EmployeeCode"
    by "TransactionDate"
    with unique combo of "ProjectCode", "PhaseCode", "TaskCode"
    Cheers, Peter

    Hi, Peter,
    PJS5 wrote:
    Thanks Frank for the quick response. Ok, here goes;
    The TABLES already exist and I am only pulling the data for the columns in my SELECT statement so no CREATE of INSERT as such.Post CREATE TABLE and INSERT statements so that the people who want to help you can re-create the problem and test their ideas.
    The data is in Oracle 10g 10.1.0.2.0Perfect!
    So you want totals that represent the entire day for a given employee.
    Yes, but rows are by the unique combo per employee of "ProjectCode", "PhaseCode", "TaskCode"So a row of output will represent a distinct combination of employee, day, ProjectCode, PhaseCode and TaskCode, and that one output row may correspond to more than one row of input; is that right?
    eg Tom works on 4 unique "ProjectCode/PhaseCode/TaskCode" efforts on "TransactionDate"What does "effort" mean here? If I could look at some actaul data (or actual fake data; don't post anything like real credit card numbers) and the results you want from that data, perhaps it would be clear.
    One of those unique "ProjectCode/PhaseCode/TaskCode" efforts however has 3 timesheet entries as he has added unique Descriptions of what his efforts were aimed at achieving.
    We are not extracting the Descriptions and thereby want to SUM those 3 timesheet entries into one row.
    Do you also want a total for each employee, over all days? No thanks
    Do you want a grand total for all employees and all days? No thanks
    Do you want the totals on the same output rows as your current reuslts? That would be handy
    If so, use the analytic SUM function. I'm not familiar with this
    Do you want separate rows for the the totals? That could helpPost the exact results you want from a small set of given data. It's fine to describe the results, as you did above, but describe them in addition to (not instead of) actually showing them.
    Does that make my questions easier to follow?It looks good, but without some sample data and the results you want from that data, I can't say for sure.
    Please post CREATE TABLE and INSERT statements (relevant columns only) for a little sample data, so that I (and the others who want to help you) can see exactly what your tables are like, and actually try our solutions. Simplify as much as possible. For example, if the data is actually coming from a multi-table join, but you already know how to join all the tables perfectly, then pretend all the data is in one table, and post CREATE TABLE and INSERT statements for that one table that looks sort of like your current result set. Post just enough data to show what you want to do. Based on what you've said so far, I'm guessing that 10 to 20 rows of raw data, resulting in 3 to 7 rows of output could give a nice example.
    Also, post the exact results you want from the sample data you post. Explain, with specific examples, how you get those results from that data.
    If parts of your desired output are optional (that is, if some parts "would be handy" or "could help") then post a couple of different sets of results from the same data, and explain, something like this:
    "What I'd really love to get for results is" ...
    but, if that makes things really complicated or inefficient, I don't absolutely need ... or ...,
    so I'd settle for these results: ..."
    I know it's a lot of work to post all this information, but it's really necessary. If I could help you without making you do all this, then I would. Unfortunately, I really don't have a good idea of where you're coming from or where you want to go.
    Edited by: Frank Kulash on Oct 19, 2010 8:01 PM

  • Decimal places diferent in BO SUM function than from DB

    Hi,
    I have a column from a Netezza database with 2 decimal places, if I apply a sum() function in BO (report) the decimal places are 4.
    The strange part is that if i do exact the same query in a DB2 database the decimal places are always two (like in DB) even if i use a sum function in report.
    There is some configuration regarding the database i'm using to set the decimal places in the report level to be the same than in DB?
    Edited: I've been studing the problem and I found using a odbc instead of a jdbc makes all the columns have 2 decimal places, and the sum problem doesn't happen. Now my issue is the division. How is possible that with the exact same values with two decimal positions, in BO and exporting to excel the last decimal place is different in some cases
    Example:
    Lets say A/B with A=13549678065,560000 and B= 21629484348,690000. With Netezza result is 62,6444803173527 and Db2  62,6444803173528
    Thanks for your time.

    I've never seen this particular problem before. Quite strange. It sounds more like an OLAP or SQL Server issue, not BPC.
    I'm not aware of any configuration on SQL server that allows you to control the decimal separator.
    I had a similar problem in the past, when my customer refused to follow the install guide instructions, and insisted that the server be set to non-US English regional settings. If I recall, the issue had to do with date formats not decimal separators. They ended up un-installing and re-installing the entire OS (with US English setup, the second time around), and then it worked fine. This was back on 5.0, and perhaps the situation has changed since then. There's a section in the master / install guide that covers the server-side language & regional settings in some detail.
    But before you look at that, try something easier -- is it possible that the cube is somehow corrupted? Do you get any errors when you process the application? Perhaps there is some data in the fact table with an invalid member ID.
    Do you get the same result in your Excel report when you use both EVDRE and EVGET?
    And if you browse the cube data in SQL Mgmt Studio (logging into the Analysis Services cube) do you see aggregated data there?
    Regards,
    Tim

  • Urgent!! Sum function for subtotals.,Exporting BA does not list Workbooks

    Hi,
    I m facing this issue when calculating subtotals in the report. When i use the sum function, the subtotals are not getting displayed. I tried usin the Cell Sum Distinct function and it sums up only if the amounts are different. For example when i have two amounts of 5.00 each, it sums as 5.00 only in the subtotal. Can anyone help me resolve this?
    Also, i m facing one more issue. When i export the BA, the user wants the list of workbooks under that that would be exported. (The list is shown when exporting the EUL as such), but the list is just blank in BA export. Is this a set up issue?
    Thanks in advance.

    Hi,
    Not all calculations can be summed correctly by Discoverer. What is the calculation that you are trying to sum?
    The workbooks are not tied to a BA as the folders used in a workbook may be in many different BAs. Therefore the workbooks are not exported with a business area. The workbooks must be exported separately.
    Rod West

  • Sum function not showing total

    Hi,
    i have to calculate sum under the report. when i use sum function it is not displaying adding total. Please let me know. How to calcuate sum?
    Thanks,
    lax

    The sum function will work as long as you follow the rules in XPATH (check this out: http://www.w3schools.com/xpath/xpath_examples.asp)
    So, basically it depends on 1) you XML data 2) conditions for the sum.
    Assuming there are no conditions and that your xml data is flat then an example would be:
    <?sum(//MYVALUE)?>
    This will sum all elements MYVALUE in the XML data regardless of its position in the tree.
    regards
    Jorge

  • SUM function to give NULL result

    I am really lost on how I can force the SUM function to give me a NULL result when at least one of the elements is a NULL value. I would appreciate any help.

    The short answer is "you can't". The slightly longer answer is the you can't because most aggregate functions work only on non-null values, so SUM silently ignores NULLS.
    However, you can take advantage of that fact to do what you want.
    SQL> SELECT * FROM t;
            ID GROUPCOL
            33 GROUPA
            50 GROUPA
             5 GROUPA
            21 GROUPA
            43 GROUPA
            58 GROUPB
            10 GROUPB
            29 GROUPB
            10 GROUPB
            37 GROUPB
               GROUPA
    SQL> SELECT groupcol, SUM(id) sum_id, COUNT(*) count_all,
      2               COUNT(id) count_id
      3        FROM t
      4        GROUP BY groupcol;
    GROUPCOL       SUM_ID  COUNT_ALL   COUNT_ID
    GROUPA            152          6          5
    GROUPB            144          5          5Note that count_all is different than count_id. So, we can wrap this query in another to return NULL for the sum of groupa.
    SQL> SELECT groupcol, CASE WHEN count_all = count_id THEN sum_id
      2                        ELSE NULL END sum_id
      3  FROM (SELECT groupcol, SUM(id) sum_id, COUNT(*) count_all,
      4               COUNT(id) count_id
      5        FROM t
      6        GROUP BY groupcol);
    GROUPCOL       SUM_ID
    GROUPA
    GROUPB            144Although, I too would be interested in the answer to 405764's question.
    John

  • Incorrect sum function result in invoice

    I'm a Numbers noob, so apologies if this has been covered elsewhere, but I couldn't find it.This issue causes me no issues in Excel but doesn't work properly in Numbers, so I'm wondering what gives.
    I have an invoice for my clients where I have multiple rows, each with a service item, followed by the number of hours spent on that, followed by a cell with an EQUAL function, ie 2/3 of an hour x $40 per hour, which correctly EQUALs as $26.66. (The EQUAL cell is set to formatted as currency to 2 decimal places)
    If a second item appears that has say 1/3 of an hour x $40 per hour, this correctly EQUALs as $13.33.
    However when I total the EQUALs column with a SUM function, it shows $40, not $39.99. As the cells are only formatted to 2 decimal points, and all are formatted as currency, where could the error be happening?
    My clients accounting dept keeps coming back and complaining about my invoices being incorrect... I can't believe that Numbers can't do a SUM function.

    Hi Fritz,
    1/3 and 2/3 are not exact numbers. They go to infinity.
    Column B is formatted as Fraction
    Column C is formatted as Number (Decimals Auto)
    Formula in C2 (and Fill Down)
    =B2
    Formula in D2 (and Fill Down)
    =C2×40
    The Numbers app is correctly rounding to two decimal places.
    If you display Column C as Number to 2 decimal places,
    Again, correct.
    Your clients are quibbling about $0.0000000000000000000 (to infinity) then a infinitesimal part of 1 cent. Which is nonsense!
    Shops also round the total invoice up or down.
    If you work an extra 10 minutes, that will equal exactly 0.5 hours.
    If you work 5 minutes less, that will equal exactly 0.25 hours.
    No rounding needed, and no argument from your clients!
    Regards,
    Ian.

  • SUM function resulting WRONG values when some cell contains a string

    A very strange problem that can result in wrong financial calculations and big mistakes...
    If we have SUM function for some range of cells and one of them is treated as text string (I mean it's number in fact but Number is sure it's text string). than SUM function calulates ALL cells except this sell silently without errors and results in wrong result.
    For example we have cells and values
    A B
    =====
    1| 15 USD
    2| 0 USD
    3| 37 USD
    4| 1 USD
    5| 3 USD
    here the function SUM(B1:B5) should provide the result "56 USD"
    But if cell B5 is treated as text string (it can be still displayed as "3 USD" so we don't know it's treated as text string for some reason) than SUM(B1:B5) swill answer "53 USD".
    The problem is we DON'T know cell B5 is treated as text and we are fully sure that we have the correct sum of all 5 cells, in reality we see sum of 4 cells only....
    I think anybody working with financial or other important data can imagine how dangerous this SUM behaviour is.... I encountered several times that when importing data from Excel or by other ways numbers are imported as text strings. So if I have a lot of cells I'm not sure if all those cells are correctly styled or some of them for some unknown reason is treated as text string.
    In Microsoft Excel there is a very right solution. In MS Excel if any cell in the SUM is wrong format the SUM function simply provides error as a result. But in Numbers SUM doesn't tell us about error, it simply provides us with a wrong result!
    With formal logic the way SUM works in Numbers is total idiotism. If I ask to SUM B1:B5 than I definitely ask to sum ALL 5 cells, not 4, not 3, not 6 but 5 definite cells. If Numbers can't sum those exactly those 5 cells the only answer of the function should be ERROR.
    But Apple Numbers answers me some result of summing those cells that it's able to sum. Apple Numbers SUM function is not confused that I asked for SUM of 5 (not 4 or 3) cells and I expect to have this sum as a result.
    In fact Apple uses the right logic when we use another formula. If we use =B1B2+B3+B4B5 and any cell contains text string that we'll have error result the sam as in Microsoft Excel. So in this example Numbers behaves correctly.
    So why SUM (B1:B5) can provide totally different result as =B1B2+B3+B4B5?

    alexb2 wrote:
    So when I set format for my number as my local currency it's displayed as 123 XXX (XXX is my currency but it's not in latin). I see it's not only displayed but also stored as 123 XXX. That's different from Excel that stores only numbers in cells and shows number with prefix or suffix - Numbers storex number with prefix or suffix.
    No, you get this behavior because the original sheet is displaying values as currencies. I assumes that the import process pass it as a string because he doesn't recognize it as a currency value. As far as I know, Numbers stores the currency entries as a pure number and an indicator of the used currency.
    Here is an example.
    (a) the description of the numerical value (I underlined it: 456)
    <sf:number-cell sf:flags="4" sf:value="456" sf:col="1" sf:row="2">
    <sf:cell-style-ref sfa:IDREF="SFTCellStyle-46"/>
    <sf:content-size sfa:w="58.659881591796875" sfa:h="14"/>
    </sf:number-cell>
    (b) the description of the format (I underlined the used currency: XAM)
    <sf:cell-style sfa:ID="SFTCellStyle-46" sf:cell-style-default-line-height="12" sf:parent-ident="tabular-Basic-body-cell-style-id">
    <sf:property-map>
    <sf:SFTCellStylePropertyNumberFormat>
    <sf:number-format sfa:ID="SFTNumberFormat-23" sf:format-type="1" sf:format-string="#,##0.00 &#xA4;;-#,##0.00 &#xA4;" sf:format-decimal-places="2" sf:format-currency-code="XAM" sf:format-negative-style="0" sf:format-show-thousands-separator="true" sf:format-fraction-accuracy="-3" sf:format-use-accounting-style="false"/>
    </sf:SFTCellStylePropertyNumberFormat>
    <sf:SFTCellStylePropertyImplicitFormatType>
    <sf:number sfa:number="256" sfa:type="i"/>
    </sf:SFTCellStylePropertyImplicitFormatType>
    <sf:SFTCellStylePropertyFormatType>
    <sf:number sfa:number="257" sfa:type="i"/>
    </sf:SFTCellStylePropertyFormatType>
    </sf:property-map>
    </sf:cell-style>
    Of course, if the original currency string is not recognized, it can't be described as such a feature and the value is treated as a simple string.
    So may be at some moment my 123 XXX is treated like string value.
    Yes, find and replace is a nice tool when importing data - thanks for the tip. the last problem is with already Numbers files that were imported not today (or even createde as Numbers file) where some cell becomes string value after some editing.
    Here again, if you edit a currency string and replace it to a not recognized one, the result will be logically a string.
    There is an other way to give this result:
    copy a value from a cell formatted as XAM currency (just an example)
    paste it in a cell whose format is currency Euro (once again it's just an example).
    The result will be a string.
    The culprit is not the program, it's the user.
    I had several times this situation and last time I found error only because I have my budget in 2 programs - in Numbers and in another special budgeting program. As each program has advantages I have in fact 2 instances of the same budget.
    And when I changed some string in Numbers and another program I noticed the sum is different. I was sure it's another program somewhere buggy but noticed than Numbers simply ignores one of the budget strings and sums without it... In fact it was even not the string I changed, I remember I changed the buggy string about a week ago but I haven't compared budgets that time so my budget had a mistake for some time till I noticed it. If I used only Numbers without copy of budget in another program may be even today I won't notice the mistake.
    The same situation happened not once.
    I think that the choice made by Apple for SUM() is correct. You feel that it is wrong. It's useless to debate more, we will not change the behavior of the function.
    I try to give a workaround.
    The neater one is to add columns as I described in my first response.
    The given formula will clearly flag cells which aren't containing numerical values. If you move the SUM from the original range to the new one, the oddities will be flagged automatically.
    Here is an alternate workaround:
    The currency is XAM.
    In B4 I introduced a typo so the value is no longer a numerical one.
    Given that, the sum in the footer doesn't count the 34 (which is the normal behavior).
    In column C1 I entered =1*B
    which flagged the bad cell.
    The alternate is to use an auxiliary table like aux1
    In A1 I entered:
    =IF(ISERROR(INDIRECT(ADDRESS(ROW(),COLUMN(),,,"main"))),"",IF(ISBLANK(INDIRECT(A DDRESS(ROW(),COLUMN(),,,"main"))),"",1*INDIRECT(ADDRESS(ROW(),COLUMN(),,,"main") )))
    Exactly the same formula in B1, C1, D1, …
    So, the table will automatically grab the contents of the main table (just take care to insert more columns in aux1 than in main)
    In the footer row of aux1, insert a sum formula for columns where there is required.
    Looking at this footer will flag columns where a value may be "wrong" so, it will be necessary (but easy) to scan the column's content to find the red triangle(s).
    Yvan KOENIG (from FRANCE lundi 13 octobre 2008 13:27:40)

Maybe you are looking for

  • Trying to understand advantages of Apple TV

    My setup:  Multiple family members have iphones and Ipads.  We share the same iTunes account.  We use iCloud Match to share iTunes purchased and uploaded MP3 files.  I have a wireless home network and 2 home entertainment centers in different rooms. 

  • Disappointed in Verizon...willing to lose a customer

    I called a week ago to ask Verizon for some help.  My husband and I just bought our first home.  We checked Verizon's map of coverage, and it said our new house was in a good coverage area.  The day we signed papers on the house, I came over to clean

  • Live Office one query per tabs or graphe?

    hi, we have this problem: whe have to insert a webi report with many tab and graph in a PPT doc with LO BOXI31sp3. during the refresh, LO generate so many requests (toad chek) as tabs and graph it's normal ? thank's

  • TS3992 IOS 8 & cloud not backing up

    Managed to restore all my things from iCloud onto my new iPhone 6 but now when I try back my iPhone 6 to the cloud it can't because each time you select back up it boots me off the wifi....restarted phone and router and the same occurs. Any ideas?

  • Netpoint 5.96: Best way to force a theme/catalog to a B2B customer

    Hi, what will be best way to assign a B2B customer with a theme/catalog. login will be requierd as the first step which is setup in the installer and by the customer industry restrict to a specific theme/catalog thanks MM