Sum defaults to different column

I have set up a numbers templet for stock prices where I only need to enter the closing price for each stock to update the spreadsheet. I would like the profit to fall in one column and the loss to fall in a different column. Is this possible?

Hi Richard,
Enclose the formula calculating profit/loss in IF statements, following this model:
PROFIT column: =IF(formula>=0,formula,"")
   LOSS column: =IF(formula<0,formula,"")
If you want the loss figure to appear as a positive number, use this version of the LOSS formula:
   LOSS column: =IF(formula<0,ABS(formula),"")
Regards,
Barry

Similar Messages

  • How to sum different column in the same table

    Hi everyone
    I would like to know how can I make the sum of different column in the same table using apex
    exple:
    TR_PROJ_BIL_TRIM.ENTPIDFISC as ENTPIDFISC,
        TR_PROJ_BIL_TRIM.EXEANNEE as EXEANNEE,
        TR_PROJ_BIL_TRIM.PROJBILTRIMT1PREV as PROJBILTRIMT1PREV,
        TR_PROJ_BIL_TRIM.PROJBILTRIMT2PREV as PROJBILTRIMT2PREV,
        trunc( TR_PROJ_BIL_TRIM.PROJBILTRIMT1PREV)+(TR_PROJ_BIL_TRIM.PROJBILTRIMT2PREV)
    from TR_PROJ_BIL_TRIM TR_PROJ_BIL_TRIM
    group by TR_PROJ_BIL_TRIM.ENTPIDFISC,TR_PROJ_BIL_TRIM.EXEANNEE
    but while trying to run this script i get this error message:"ORA-00979: not a GROUP BY expression"
    thanks for reading me and I hope to hear from you soon

    Hi,
    Your question do not have anything do with APEX.
    It is pure SQL question and you will get better answer this kind questions from SQL and PL/SQL forum
    You need have GROUP BY when you use aggregate functions like SUM.
    I assume you like just add two columns.
    Try
    SELECT ENTPIDFISC
        ,EXEANNEE
        ,PROJBILTRIMT1PREV
        ,PROJBILTRIMT2PREV
        ,trunc(PROJBILTRIMT1PREV) + (PROJBILTRIMT2PREV)
    FROM TR_PROJ_BIL_TRIM
    Regards,
    Jari

  • Sum two different columns from two different tables

    Can you select and sum two different columns, from two different tables in the same sql statement?
    i.e.
    table1
    Item----OnHand_Qty
    A--------10
    A--------15
    B--------10
    B--------10
    C--------20
    table2
    Item----Trx_Qty
    A--------2
    A--------4
    A--------6
    B--------1
    B--------1
    C--------4
    I'm looking for the following results from a query
    Item----Sum(Onhand_Qty)---Sum(Trx_Qty)
    A--------25

    Like this?
    SQL> create table table1 (item,onhand_qty)
      2  as
      3  select 'A', 10 from dual union all
      4  select 'A', 15 from dual union all
      5  select 'B', 10 from dual union all
      6  select 'B', 10 from dual union all
      7  select 'C', 20 from dual union all
      8  select 'D', 30 from dual
      9  /
    Tabel is aangemaakt.
    SQL> create table table2 (item, trx_qty)
      2  as
      3  select 'A', 2 from dual union all
      4  select 'A', 4 from dual union all
      5  select 'A', 6 from dual union all
      6  select 'B', 1 from dual union all
      7  select 'B', 1 from dual union all
      8  select 'C', 4 from dual union all
      9  select 'E', 3 from dual
    10  /
    Tabel is aangemaakt.
    SQL> select nvl(t1.item,t2.item) item
      2       , t1.sum_onhand_qty
      3       , t2.sum_trx_qty
      4    from ( select item, sum(onhand_qty) sum_onhand_qty
      5             from table1
      6            group by item
      7         ) t1
      8         full outer join
      9         ( select item, sum(trx_qty) sum_trx_qty
    10             from table2
    11            group by item
    12         ) t2
    13         on (t1.item = t2.item)
    14  /
    I SUM_ONHAND_QTY SUM_TRX_QTY
    A             25          12
    B             20           2
    C             20           4
    E                          3
    D             30
    5 rijen zijn geselecteerd.Regards,
    Rob.

  • Can I get multiple sums in a single column based on a "code" I place.

    After importing a file of check/debit card activity from my bank, can I 'code' the line items based on tax categories ie Utilities, Medical expenses, Auto expenses, etc. and then get sums for each based on that code I placed in a single column? That would mean multiple sums in a single column based on the code used for each tax related expense. For instance, I would put UT in the column for utilities expenses and MED in the same column if it were a medical expense. I would then want the sum for all items in that column for each item code. Is this possible or do I need to use a different approach to get this information.

    My guess is that the SUMIF function may be your friend.
    It's well described in the *iWork Formulas and Functions User Guid*e which every user may download from the Help menu.
    Yvan KOENIG (VALLAURIS, France) samedi 2 janvier 2010 21:56:39

  • Adding up entries of 2 different columns of a table in a single view column

    Hi All,
             I have a requirement wherein I have to add up the entries of 2 different columns of 2 different database tables and show it in one column of a View.
    Eg. Table A has column A and Table B has column B. I create a view C with column C.
    Now Col C = Col A + Col B
    Can anyone please let me know how this view can be created?
    Thanks,
    Momdipa

    Hi Momdipa,
    ABAP Table View does not support dynamic arithmetic operations. So, you can't achieve this business logic in the view. There are no operators in the view which can help you to do this.
    If you need this functionality, you need to create a ABAP Report to calculate the sum on the execution of the Report. And then you can update the View based on your own business logic.
    Hope this helps.
    Thanks,
    Samantak.

  • How can I get these two results in two different columns?

    SELECT COUNT(attr_id)
    FROM pv_attribute
    WHERE port_id = 322;
    SELECT COUNT(attr_id)
    FROM pv_attribute
    WHERE port_id = 323;
    How can I get these two results in two different columns?
    Thanks

    So Jens made a tiny mistake with the column name... shame you couldn't be bothered to research Pivoting so you could have corrected the mistake (possibly it was deliberate *{:-) ) and learnt something.
    with pv_attribute as (select 16123 attr_id, 322 port_id from dual union all
                          select 16123 attr_id, 322 port_id from dual union all
                          select 19223 attr_id, 322 port_id from dual union all
                          select 11193 attr_id, 323 port_id from dual union all
                          select 13163 attr_id, 323 port_id from dual)
    -- end of test data setup
    select sum(decode(port_id, 322, 1, 0)) cnt_322,
           sum(decode(port_id, 323, 1, 0)) cnt_323
    from   pv_attribute
    where  port_id in (322, 323)

  • Display two different column types in cross tab

    I am using Cross Tab template in crystal XI and I have to show two different column types one is of type int and other is of type string. Below is the format of the report
                                  AmountGiven             Amount Spent            Attended
    Mike                       5000                              3000                         Yes
    Steve                     200                                 200                           No
    Is there a way I can do this showing "yes" or "no" in the third column???
    Thanks...

    Hi
    If you are trying to show "yes" or "no" for a column value in a cross tab, then yes we can try using a formula for it.
    I would suggest you 2 ways that you can try at your end:
    1.
    a) Create a formula in the cross tab expert and write your condition.
    for eg: if Sum({Orders.Order amount}) > 5000 then "yes" else "no"
    b) Then select that formula in the summarized fields in cross tab expert and change the summary to MODE.
    c) You can see the "yes" and "no" Within the same box.
    2.
    a) Add a field to the colums in the cross tab expert.
    b) A column gets inserted in the cross tab.
    c) Right click the field and select format field.
    d) Go to Common tab and write a formula for the display string.
    e) Write the condition in that formula.
    f) You can see a new column with the expected values.
    Hope this helps you..
    Please revert incase of any queries.
    Regards
    Pradeep Hulke

  • Getting DISTINCT count from two different columns

    Hi all,
    I have following query which gives currency code from two different tables. I would like to get the distinct count of currency codes from these two different columns.
    SELECT eb.person_seq_id, eb.bonus_amount, eb.currency_cd, ed.currency_cd_host
    FROM fr_emp_bonuses eb, fr_emp_details ed, fr_periods p
    WHERE eb.person_seq_id = ed.person_seq_id AND ed.period_seq_id = eb.period_seq_id
    AND ed.period_seq_id = p.period_seq_id AND p.period_status = 'CURRENT'
    AND eb.bonus_amount >= 0 AND eb.person_seq_id = 3525125;
    This query gives following result
    3525125     240000     USD     INR
    3525125     0      USD     INR
    3525125     60000      USD     INR
    3525125     50000      USD     INR
    There are two distinct currency codes (USD, INR) and total amount is 350000. So I am looking for a query to give me the following result
    3525125     350000 2
    Thanks in advance

    Hi,
    Here's one way:
    WITH     original_query     AS
         SELECT  eb.person_seq_id
         ,     eb.bonus_amount
         ,     eb.currency_cd
         ,     ed.currency_cd_host
         FROM     fr_emp_bonuses         eb
         ,     fr_emp_details          ed
         ,     fr_periods          p
         WHERE      eb.person_seq_id    = ed.person_seq_id
         AND      ed.period_seq_id    = eb.period_seq_id
         AND      ed.period_seq_id    = p.period_seq_id
         AND      p.period_status         = 'CURRENT'
         AND      eb.bonus_amount     >= 0
         AND     eb.person_seq_id    = 3525125
    ,     unpivoted_data     AS
         SELECT     person_seq_id
         ,     bonus_amount
         ,     currency_cd
         FROM     original_query
        UNION ALL
            SELECT  person_seq_id
         ,     0               AS bonus_amount
         ,     currency_cd_host     AS currency_cd
         FROM     original_query
    SELECT       person_seq_id
    ,       SUM (bonus_amount)          AS total_bonus_amount
    ,       COUNT (DISTINCT currency_cd)     AS distinct_currency_cds
    FROM       unpivoted_data
    GROUP BY  person_seq_id
    ;There may be a shorter, more efficient way to get the same results, but without knowing more about your tables, I can't tell.
    The tricky thing is getting two columns (currency_cd and currencuy_cd_host in this case) counted together. You can't simply say
    COUNT (DISTINCT eb.currency_cd) +
    COUNT (DISTINCT ed.currency_code_host)That happens to get the correct result with the sample data you posted, but what if you had data like thEe following?
    currency_cd     currency_cd_host
    INR          USD
    USD          INRHere, the count of distinct currency_cds is 2, and the count of distinct currency_cd_hsots is also 2. Does that mean the grand total is 2 + 2 = 4? No, the 2 codes in one column arte the same 2 codes as in the other column. We need to get both currency_cd and currency_cd_hsot into the same column, and then do COUNT (DISTINCT ...) on that combined column. A UNION, as shown above, will certainly do that, starting with your query as you posted it. The query you posted isn't necessarily the best frist step towards this result, however, so there may be a much better approach, depending on your tables.
    Edited by: Frank Kulash on Feb 1, 2012 6:21 PM
    Here's a slightly shorter, and probably more efficient way to get the same results:
    WITH     cntr     AS
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL     <= 2
    SELECT       eb.person_seq_id
    ,       SUM (eb.bonus_amount)          AS total-amount
    ,       COUNT ( DISTINCT CASE
                        WHEN  c.n = 1
                        THEN  eb.currency_cd
                        ELSE  ed.currency_cd_host
                      END
              )               AS distinct_currency_cds
    FROM       fr_emp_bonuses    eb
    ,       fr_emp_details    ed
    ,       fr_periods          p
    ,       cntr              c
    WHERE        eb.person_seq_id  = ed.person_seq_id
    AND        ed.period_seq_id  = eb.period_seq_id
    AND        ed.period_seq_id  = p.period_seq_id
    AND        p.period_status   = 'CURRENT'
    AND        eb.bonus_amount   >= 0
    AND       eb.person_seq_i   = 3525125
    --       NOTE: no join condition involving c; we really do want a cross-join
    GROUP BY  eb.person_seq_id
    ;

  • Sales Amount from one column of period (FY-2012, FY-2013) to 2 different columns

    Hi dudes,
    I'm having some difficulties in getting the Sales Amount  from one column of period (Fiscal Year containing 2012 and 2013) and put it into 2 different columns (Sales 2012 and Sales 2013. I have 3 fields in my dataset: Sales (for all the years), Fiscal
    Year (more than 5 years) and month (which I can neglect).
    For the moment, my situation is as follows:
    Fiscal Year          Month       
    Sales
    2012                      Jan           $72,500
                                   Feb          $80,200
                                   Dec          $79,500
    2013                      Jan           $51,000
                                   Feb          $62,800
                                   Dec          $85,000
    However I would like to get a scenario as follows:
        Month       
    Sales 2012          Sales 2013
         Jan              $72,500                  $51,000
         Feb             $80,200                   $62,800
         Dec             $79,500                   $85,000
    Once I have this, I would be much easier for me to do the difference between the two sales period.
    Is there any expression I can use?
    I tried to filter from the Group properties the sales amount for Fiscal Year 2012 on 1 column, and on on another column, the sales amount for Fiscal Year 2013 but it is giving me the same values.
    Thank you very much dudes.

    Hi Stan,
    According to your description, we can use a matrix control to achieve your requirement. For more details, please refer to the following steps:
    Drag a matrix from Toolbox to design surface.
    Insert Month field to the first column.
    Insert Fiscal_Year field to the first row of the second column.
    Insert Sales field to the second row of the second column.
    Right-click the second column to add a column with Outside Group-Right option.
    Type the expression below to the second row of the third column:
    =sum(iif(Fields!Fiscal_Year.Value=‘2012’,CDbl(Fields!Sales.Value),CDbl(0)))-sum(iif(Fields!Fiscal_Year.Value=‘2013’,CDbl(Fields!Sales.Value),CDbl(0)))
    The following screenshot id for your reference:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to get multiple records in one row and different column

    Hi All,
    I am using oracle database 11g
    and i have a two tables table_1, table_2
    table_1 having columns
    emp_no
    first_name
    middle_name
    last_name
    email
    and table_2 having columns
    emp_no
    phone_type
    phone_number
    and having entires
    emp_no phone_type phone_number
    1001 MOB 9451421452
    1001 WEMG 235153654
    1001 EMG 652341536
    1002 MOB 9987526312
    1003 WEMG 5332621456
    1004 EMG 59612356
    Now i want the output of values with phone type as MOB or WEMG in a single row with different columns
    emp_no first_name middle_name last_name email mobile officeno
    1001 mark null k [email protected] 9451421452 235153654
    1002 john cena gary [email protected] 9987526312 null
    1003 dany null craig [email protected] null 5332621456
    1004 donald finn sian [email protected] null null
    can i have any inputs to achive this???
    Regards
    $sid

    Frank Kulash wrote:
    sonething like this:Frank, you missed aggregate function (pivot requires one). However main thing is it will cause ORA-01748:
    with table_1 as (
                     select 1001 emp_no,'mark' first_name,null middle_name,'k'last_name,'[email protected]' email from dual union all
                     select 1002,'john','cena','gary','[email protected]' from dual union all
                     select 1003,'dany',null,'craig','[email protected] null' from dual union all
                     select 1004,'donald','finn','sian','[email protected]' from dual
         table_2 as (
                     select 1001 emp_no,'MOB' phone_type,9451421452 phone_number from dual union all
                     select 1001,'WEMG',235153654 from dual union all
                     select 1001,'EMG',652341536 from dual union all
                     select 1002,'MOB',9987526312 from dual union all
                     select 1003,'WEMG',5332621456 from dual union all
                     select 1004,'EMG',59612356 from dual
    SELECT     *
    FROM     table_1      t1
    JOIN     table_2      t2  ON  t1.emp_no = t2.emp_no
    PIVOT     (    max(t2.phone_number)
         FOR  t2.phone_type  IN  ( 'MOB'   AS mob
                                 , 'WEMG'  AS wemg
            FOR  t2.phone_type  IN  ( 'MOB'   AS mob
    ERROR at line 19:
    ORA-01748: only simple column names allowed hereYou need to:
    with table_1 as (
                     select 1001 emp_no,'mark' first_name,null middle_name,'k' last_name,'[email protected]' email from dual union all
                     select 1002,'john','cena','gary','[email protected]' from dual union all
                     select 1003,'dany',null,'craig','[email protected] null' from dual union all
                     select 1004,'donald','finn','sian','[email protected]' from dual
         table_2 as (
                     select 1001 emp_no,'MOB' phone_type,9451421452 phone_number from dual union all
                     select 1001,'WEMG',235153654 from dual union all
                     select 1001,'EMG',652341536 from dual union all
                     select 1002,'MOB',9987526312 from dual union all
                     select 1003,'WEMG',5332621456 from dual union all
                     select 1004,'EMG',59612356 from dual
         table_3 as (
                     select  t1.emp_no,first_name,middle_name,last_name,email,
                             phone_type,phone_number
                       FROM     table_1      t1
                       LEFT JOIN     table_2      t2  ON  t1.emp_no = t2.emp_no
    SELECT     *
    FROM     table_3
    PIVOT     (    max(phone_number)
         FOR  phone_type  IN  ( 'MOB'   AS mob
                                 , 'WEMG'  AS wemg
        EMP_NO FIRST_ MIDD LAST_ EMAIL                     MOB       WEMG
          1004 donald finn sian  [email protected]
          1003 dany        craig [email protected] null            5332621456
          1001 mark        k     [email protected]      9451421452  235153654
          1002 john   cena gary  [email protected]    9987526312
    SQL>SY.

  • Not able to display data in different columns using Unicode encoding

    Hi,
    Iam using Unicode encoding in my Java appln to support Japanese characters while downloading CSV report. But using the Unicode encoding displays all data in the first column of Excel sheet.
    Please let me know how to display data in different columns using Unicode encoding in Excel sheet.

    Hi Venkat,
    After extracting data into DSO check the request whether active or not.
    Check data in DSO in contents.
    If is there any restrictions on info providers in Queries.
    Let us know status clearly.......
    Reg
    Pra

  • Amount of a sum in a different currency

    looking for function or other way to check the amount of a sum in a different currency for a certain exchange type according the currencies and exchange rate definition.
    Thanks

    Hi,
    You can use CONVERT_TO_LOCAL_CURRENCY function.
    Regards,
    Eli

  • IR - if count (primary key) cannot change to count different column

    Apex 4.1.1.00.23 Windows 7 IE8 / Firefox 16
    If I add a Group By and Count to an Interactive report and choose the primary key column as the one to Count, run the report and then edit the Group By to count a different column, the result set does not change, and if I edit the Group By again it shows that the Counted column has reverted back to the primary key column.
    If I initially choose a different column I can change it and rerun the report successfully, but once I choose the primary key column it cannot be changed. This seems to happen on all applications and all browsers. Is it a bug in Apex?
    Thanks,
    Nick.

    I've tried this in 4.1.0.00.32: works normally. In 4.1.1.00.23 however i'm getting the weird behaviour: you can count on any column, but the moment you count the same column as the one grouped on you can not change the column back to another one anymore. Something which works fine in 4.1.0.00.32.

  • BO xi 3.1 u2013 schedule a template for multiple reports with different column

    Hi,
    I need to migrate the existing reports from SQL Server Reporting Services to BO, and the column order in the report is very important to the clients since clients have existing code to ingest these reports into their database. Now I want to schedule a single template with different parameters for all reports in BO, or create a single template with lot of parameters for all reports. My question is how I might use one template to create multiple reports with different column orders in the reports?
    For example, client A has the following column order in their report: firstName, LastName, DateBirth, SSN. Client B has the following column order in their report: SSN, DateBirth, LastName, FirstName. Can I use one template to create these multiple reports?
    Thanks!

    Hi,
    The only approach I can think of is to create a template report which uses variables
    For each column you would need to variable
    v_columnAName and v_columnAValue
    v_columnAName would have a if statement in it
    =if([client]="clientA" or [client]="clientC";NameOf([firstName]);if([client]="clientB";NameOf([SSN]);NameOf([lastName]));
    v_columnA would have a if statement in it
    =if([client]="clientA" or [client]="clientC";[firstName];if([client]="clientB";[SSN],[lastName]));
    This would only work when you had a small set of clients.
    This might be more managable if it was done in the universe
    Regards
    Alan

  • Different number of rows for different columns in JTable

    hi
    I need to create a JTable with different number of rows for different columns...
    Also the rowheight should be different in each column...
    say there is a JTable with 2 columns... Col1 having 5 rows and column 2 having 2 rows...
    The rowHeight in Col2 should be an integer multiple of Rowheight in Col1
    how do I do this ??
    can anybody send me some sample code ?????
    thanx in advance

    How about nesting JTables with 1 row and many columns in a JTable with 1 column and many rows.
    Or you could leave the extra columns null/blank.
    You could use a GridBagLayout and put a panel in each group of cells and not use JTable at all.
    It would help if you were more specific about how you wanted it to appear and behave.

Maybe you are looking for