How to SUM in REUSE_ALV_GRID_DISPLAY ?

Hi,
I have below the code that I use to sort 1 column and sum 3 columns;
PERFORM sort_item USING 'ARBPL' 'X' 'X'.
PERFORM sum_item USING 'NO_OPR' 'X' 'X'.
PERFORM sum_item USING 'LMNGA' 'X' 'X'.
PERFORM sum_item USING 'QTY_MTRS' 'X' 'X'.
FORM sort_item USING fieldname up subtot.
  DATA: ls_sort TYPE slis_sortinfo_alv .
  CLEAR ls_sort.
  ls_sort-fieldname = fieldname.
  ls_sort-up        = up.
  ls_sort-subtot    = subtot.
  APPEND ls_sort TO g_sort.
ENDFORM.
FORM sum_item USING fieldname group subtot.
  DATA: ls_sum TYPE slis_sortinfo_alv .
  CLEAR ls_sum.
  ls_sum-fieldname = fieldname.
  ls_sum-group     = group.
  ls_sum-subtot    = subtot.
  APPEND ls_sum TO g_sort.
ENDFORM.
The g_sort is attached to the REUSE_ALV_GRID_DISPLAY as follows;
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK                 = ' '
    I_BYPASSING_BUFFER                = ' '
    I_BUFFER_ACTIVE                   = ' '
    I_CALLBACK_PROGRAM                = ' '
    I_CALLBACK_PF_STATUS_SET          = ' '
    I_CALLBACK_USER_COMMAND           = ' '
    I_CALLBACK_TOP_OF_PAGE            = ' '
    I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    I_CALLBACK_HTML_END_OF_LIST       = ' '
    I_STRUCTURE_NAME                  =
    I_BACKGROUND_ID                   = ' '
    I_GRID_TITLE                      =
    I_GRID_SETTINGS                   =
      IS_LAYOUT                         = g_layout
      IT_FIELDCAT                       = g_fieldcat
    IT_EXCLUDING                      =
    IT_SPECIAL_GROUPS                 =
      IT_SORT                           = g_sort
    IT_FILTER                         =
    IS_SEL_HIDE                       =
    I_DEFAULT                         = 'X'
      I_SAVE                            = 'U'
      IS_VARIANT                        = ls_variant
    IT_EVENTS                         =
    IT_EVENT_EXIT                     =
    IS_PRINT                          =
    IS_REPREP_ID                      =
    I_SCREEN_START_COLUMN             = 0
    I_SCREEN_START_LINE               = 0
    I_SCREEN_END_COLUMN               = 0
    I_SCREEN_END_LINE                 = 0
    I_HTML_HEIGHT_TOP                 = 0
    I_HTML_HEIGHT_END                 = 0
    IT_ALV_GRAPHICS                   =
    IT_HYPERLINK                      =
    IT_ADD_FIELDCAT                   =
    IT_EXCEPT_QINFO                   =
    IR_SALV_FULLSCREEN_ADAPTER        =
  IMPORTING
    E_EXIT_CAUSED_BY_CALLER           =
    ES_EXIT_CAUSED_BY_USER            =
    TABLES
      T_OUTTAB                          = ittab
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2.
The 1st column get sorted but sum does not work at all, why?
Thanks,
Kishan

For that particular field in the field catalog, please try adding this line when building the catalog.
i_fieldcat-datatype   = 'QUAN'.
or try this
*& Form DEFINE_LAYOUT
text
FORM DEFINE_LAYOUT.
LAYOUT-ZEBRA = 'X'.
LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL SUM'.
LAYOUT-WINDOW_TITLEBAR = 'EXERCISE 2'.
LAYOUT-TOTALS_TEXT = 'TOTAL'.
ENDFORM. "DEFINE_LAYOUT
*& Form SORT_LIST
text
FORM SORT_LIST.
WA_SORT-FIELDNAME = 'VBELN'.
WA_SORT-TABNAME = 'IT_VBAK'.
WA_SORT-SPOS = 1.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'NETWR'.
WA_SORT-TABNAME = 'IT_VBAK'.
WA_SORT-UP = 'X'.
WA_SORT-SPOS = 2.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
ENDFORM. "SORT_LIST&----
*& Form LIST_DISP
text
FORM LIST_DISP.
PERFORM DEFINE_LAYOUT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FIELDCAT
IS_LAYOUT = LAYOUT
IT_SORT = IT_SORT
I_CALLBACK_PF_STATUS_SET = 'STATUS'
IT_EXCLUDING = I_FCODE_EXTAB
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_EVENTS = IT_EVENTS[]
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_VBAK
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "LIST_DISP
*& Form GRID_DISP
text
FORM GRID_DISP.
PERFORM DEFINE_LAYOUT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_SORT = IT_SORT
I_CALLBACK_PF_STATUS_SET = 'STATUS'
IT_EXCLUDING = I_FCODE_EXTAB
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_EVENTS = IT_EVENTS[]
TABLES
T_OUTTAB = IT_VBAK.
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "GRID_DISP

Similar Messages

  • How to sum the column in a table seperated by sign.

    How to sum the column in a table separate by sign.
    For Example:
    A B
    10 MOHAN
    -15 KUMAR
    -25 MARCH
    50 MAY

    SELECT  SUM(CASE SIGN(A) WHEN 1 THEN A ELSE NULL END) SUM_POSTIIVE,
            SUM(CASE SIGN(A) WHEN -1 THEN A ELSE NULL END) SUM_NEGATIIVE
      FROM  tbl
    /SY.

  • How to sum + group bp line items per a specific field?

    Hi,
    I found out about the SYS Numeric Query Based data definition, allowing me to sum the line items of a BP according to certain conditions.
    Now we have a more complex problem. We need to sum the line items of BP1 into the line items of BP2, grouping them by a given field. We know how to auto-create BPs on workflow events conditions, but we don't know how to sum the line items together.
    Is there a workaround?
    Thanks,
    S.R.

    We do not currently support QBDEs on line items so there isn't a way to sum values from other line items onto a line item.

  • How to sum in csv format

    How can I do a sum on a column in csv format? I am concatenating all columns in csv, so the resulting field is a string. Even if I convert it to a number, I am not sure how to sum a specific column. Any ideas?
    Thanks

    You would create the summary in the data model, and the value will be included in the output (whether that output be csv or whatever). If this doesn't help can you provide more details of the problem?
    Thanks,
    Danny

  • How to sum a column in SQL server??

    How do I sum a column called 'expenditureamount' in a sql table 'expenditureform', such that I get the total expenditure amount displayed in a text box??

    You can sum it with the SQL SUM function, of course, but what that has to do with how your program display that sum, I don't know. IOW, how you display is not anything related to JDBC, and how you SUM it is not anything related to JDBC. The first one is SQL (check on an SQL forum or Google for it) and the second depends on how you want to display it, and there are more appropriate forums than the JDBC one, for that.

  • How does SUM actually works

    Hi,
    I'm puzzled by how SUM actually works.
    I've got a table with the following fields:
    SET_OF_BOOKS_ID NOT NULL NUMBER(15)
    SUMMARY_CODE_COMBINATION_ID NOT NULL NUMBER(15)
    DETAIL_CODE_COMBINATION_ID NOT NULL NUMBER(15)
    TEMPLATE_ID NOT NULL NUMBER(15)
    LAST_UPDATED_BY NOT NULL NUMBER(15)
    LAST_UPDATE_DATE NOT NULL DATE
    ORDERING_VALUE NOT NULL VARCHAR2(25)
    Using the below, I was able to get the total value of all the ordering value.
    select sum(ordering_value) from gl_account_hierarchies where set_of_books_id = 1 and summary_code_combination_id = 1147;
    I was happy that I could get the total value but am puzzled as ordering value is of data type VARCHAR2.
    Is sum(ordering_value) a VARCHAR2 or a NUMBER then?
    I did a simple test, inserting the following record:
    insert into gl_account_hierarchies values(1,1024,1,2,3,'11-APR-2002','xyz');
    After committing, I double check by using the following statement:
    select * from gl_account_hierarchies where last_update_date = '11-APR-2002';
    and was able to retrieve the newly inserted record.
    But when I did another check with the following statement:
    select * from gl_account_hierarchies where set_of_books_id = 1 and summary_code_combination_id = 1147;
    I wasn't able to retrieve the newly inserted record.
    Why is that so? How does SUM actually works? Is the output of SUM a VARCHAR2 or NUMBERIC value?
    thanks in advance!!
    Yu S.S

    SUM() gives a number.
    What you have come across is an implicit data conversion. Basically the SQL parser doesn't reject your query as being syntactically invalid just because you're attempting a mathematical function on a non-numeric column. Instead when you execute your query SQL substitutes this
    select sum(to_number(ordering_value)) from gl_account_hierarchies where set_of_books_id = 1 and summary_code_combination_id = 1147;
    If you want to check this create a view
    create order_value as select sum(ordering_value) sum_val from gl_account_hierarchies ;
    and then desc it.
    Cheers, APC
    SUM(

  • How to sum

    Hi,
    May I know how to sum the units and amount in internal table? After summing, the value will be moved to new internal table.
    I try to do as below, but didnt get result. Perhaps something wrong? Can anyone help? Am very fresh in abap .. probably there are better ways to achieve this. Thanks.
    FORM GET_TOTAL .
    DATA : BEGIN OF WA_SUMM,
           PREV_LGORT TYPE LIPS-LGORT,
           TOTAL_LFIMG TYPE LIPS-LFIMG,
           TOTAL_STPRS TYPE MBEW-STPRS,
           TOTAL_TCOST TYPE LIPS-LFIMG,
           END OF WA_SUMM.
    DATA : IT_SUMM LIKE TABLE OF WA_SUMM.
    DATA : TOTAL_LFIMG TYPE LIPS-LFIMG,
           TOTAL_STPRS TYPE MBEW-STPRS,
           TOTAL_TCOST TYPE LIPS-LFIMG,
           PREV_LGORT TYPE LIPS-LGORT.
        SORT IT_OUTPUT BY LGORT.
        LOOP AT IT_SUMM INTO WA_SUMM.
          LOOP AT IT_OUTPUT INTO WA_OUTPUT.
          AT NEW LGORT.
              PREV_LGORT = WA_OUTPUT-LGORT.
              TOTAL_LFIMG = TOTAL_LFIMG + WA_OUTPUT-LFIMG.
              TOTAL_STPRS = TOTAL_STPRS + WA_OUTPUT-STPRS.
              TOTAL_TCOST = TOTAL_TCOST + ( TOTAL_LFIMG * TOTAL_STPRS ).
              MODIFY IT_SUMM FROM WA_SUMM TRANSPORTING PREV_LGORT TOTAL_LFIMG TOTAL_STPRS TOTAL_TCOST.
          ENDAT.
          ENDLOOP.
        ENDLOOP.

    See The sample code :
    Hi.
    TYPES: BEGIN OF G_I_DATA,
    PROFIT(4) TYPE C,
    COMPANY(4) TYPE C,
    ACCOUNT(10) TYPE C,
    AMOUNT TYPE P,
    END OF G_I_DATA.
    DATA: G_IT_DATA TYPE TABLE OF G_I_DATA,
    G_WA_DATA TYPE G_I_DATA.
    DATA: G_SUM_COMPANY TYPE P,
    G_SUM_PROFIT TYPE P,
    G_AMOUNT TYPE P.
    G_WA_DATA-PROFIT = '0001'.
    G_WA_DATA-COMPANY = '1111'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
    G_WA_DATA-AMOUNT = 2000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0001'.
    G_WA_DATA-COMPANY = '1111'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
    G_WA_DATA-AMOUNT = 3000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0001'.
    G_WA_DATA-COMPANY = '2222'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
    G_WA_DATA-AMOUNT = 4000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0001'.
    G_WA_DATA-COMPANY = '2222'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
    G_WA_DATA-AMOUNT = 5000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0002'.
    G_WA_DATA-COMPANY = '1111'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
    G_WA_DATA-AMOUNT = 2000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0002'.
    G_WA_DATA-COMPANY = '1111'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
    G_WA_DATA-AMOUNT = 3000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0002'.
    G_WA_DATA-COMPANY = '2222'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
    G_WA_DATA-AMOUNT = 4000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0002'.
    G_WA_DATA-COMPANY = '2222'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
    G_WA_DATA-AMOUNT = 5000.
    APPEND G_WA_DATA TO G_IT_DATA.
    SORT G_IT_DATA BY PROFIT COMPANY ACCOUNT.
    WRITE: /6 'ProfitCenter', 20 'CompanyCode',
    34 'Glaccount', 48 'Amount'.
    WRITE: /6 SY-ULINE(50).
    LOOP AT G_IT_DATA INTO G_WA_DATA.
    AT NEW PROFIT.
    WRITE: /6 G_WA_DATA-PROFIT.
    ENDAT.
    G_AMOUNT = G_WA_DATA-AMOUNT.
    AT NEW ACCOUNT.
    WRITE: /34 G_WA_DATA-ACCOUNT,
    48 G_AMOUNT.
    ENDAT.
    G_SUM_PROFIT = G_SUM_PROFIT + G_WA_DATA-AMOUNT.
    G_SUM_COMPANY = G_SUM_COMPANY + G_WA_DATA-AMOUNT.
    AT END OF COMPANY.
    WRITE: /20 G_WA_DATA-COMPANY,
    34 'Totle',
    48 G_SUM_COMPANY.
    CLEAR G_SUM_COMPANY.
    WRITE: /6 '*******'.
    ENDAT.
    AT END OF PROFIT.
    WRITE: /6 G_WA_DATA-PROFIT,
    20 'Totle',
    48 G_SUM_PROFIT.
    CLEAR G_SUM_PROFIT.
    WRITE: /6 '*************************************'.
    ENDAT.
    ENDLOOP.
    Please use temporary Variable and clear that variable after processing
    Reward Points if it is useful
    Thanks
    Seshu

  • How to sum values from multiple lines in a DataTable?

    I have a Lookout program which uses a DataTable to allow users to write basic programs (relay on/off times, which relays change state, and pause times).  The DataTable cursor position changes to advance from one program stage to another.  
    What I would like to do is sum up the times from all the various stages.  Can anyone suggest how I might iterate through the DataTable using Lookout alone?  
    Thanks,
    Dave 

    I have tried to make 'loops' similar to that one but Lookout shows a message that iterations or loops for a variable are not allowed.
    You can use a sequencer but there are 2 inconvenients:
    1.- For a fast computer every step of the sequencer cannot be faster than 0.1 - 0.2 seconds. If you have many iteraciones, it will take some time.
    2.- The sequencer object has a maximimum of 100 steps.
    Ryan S. Here are questions for you:
    1.- Is there a way to add in the lks file statements and or functions using existing variables? What can be done and what not?
    2.- Is there a way to insert comments in the lks file?
    Thanks in advance.
    Rudy Lopez

  • "How to sum FKIMG in VBRK and VBRP Table with sample output

    Sir\Mam\Gurus ;
    I hardly found it difficult in resolving my program in getting the sum of FKIMG inside the VBRP and VBRK tables
    The scenario is that i have one Sales Order with multiple invoices . What i need to do is to sum up the fkimg or the quanitity of specific material regardless of how many invoices the material have in a particular SO
    Example I have Sales Order number 35678952 with
    3 invoices
    Invoice # 123 with material number mat1=12, mat2=5 , mat3=7
    345 with material number mat1=7, mat2=7
    678 with material number mat1=5, mat3=10
    Output shoud be
    salesorder# 35678952
    mat1 = 24
    mat2 = 12
    mat3 = 17
    Below is my Sample Codes:
    DATA : it_vbrp_details TYPE STANDARD TABLE OF wa_vbrp_details,
    ls_vbrp_details TYPE wa_vbrp_details,
    ls_vbrp_details1 TYPE wa_vbrp_details,
    lsfinal_vbrp_details TYPE wa_vbrp_details,
    it2_vbrp_details TYPE STANDARD TABLE OF wa2_vbrp_details,
    ls2_vbrp_details TYPE wa2_vbrp_details,
    it3_vbrp_details TYPE STANDARD TABLE OF wa_vbrp_details,
    itfinal1_vbrp_details TYPE STANDARD TABLE OF wa_vbrp_details,
    itfinal2_vbrp_details TYPE STANDARD TABLE OF wa_vbrp_details,
    itfinal3_vbrp_details TYPE STANDARD TABLE OF wa_vbrp_details,
    ls3_vbrp_details TYPE wa_vbrp_details,
    rtime1 TYPE i,
    rtime2 TYPE i,
    rtime3 TYPE i,
    s_erdate type d,
    scr_erdat type d,
    s_erdate = scr_erdat.
    CALL FUNCTION 'MONTH_PLUS_DETERMINE'
    EXPORTING
    months = 1 " Negative to subtract from old date, positive to add
    olddate = s_erdate
    IMPORTING
    newdate = new_date.
    """ This is another way manual adding by days
    CALL FUNCTION 'CALCULATE_DATE'
    EXPORTING
    days = +30
    start_date = s_erdate
    IMPORTING
    result_date = new_date.
    result_date = ddate.
    REFRESH: it_vbrp_details.
    SELECT
    vbrp~matnr
    vbrp~aubel
    vbrp~aupos
    vbrp~vbeln
    vbrp~kzwi1
    vbrp~kzwi2
    vbrp~kzwi3
    vbrp~kzwi4
    vbrp~kzwi5
    vbrp~kzwi6
    vbrp~mvgr1
    vbrp~mvgr2
    vbrp~mvgr3
    vbrp~mvgr4
    vbrp~mvgr5
    vbrp~knuma_pi
    vbrp~knuma_ag
    vbrp~mwsbp
    vbrp~vkaus
    vbrp~fkimg
    vbrk~vbeln
    vbrk~fkart
    vbrk~belnr
    vbrk~xblnr
    vbrk~vbtyp
    vbrk~kunag
    vbrk~fksto
    vbap~posnr
    INTO TABLE it_vbrp_details
    FROM vbrp INNER JOIN vbrk ON vbrkvbeln EQ vbrpvbeln
    where vbeln eq gt_data-vbeln
    where vbrpaubel eq vbapvbeln
    WHERE vbrp~posnr GE ''
    AND vbrk~vbtyp EQ 'M'
    AND vbrk~fksto NE 'X'
    AND ( vbrperdat GE s_erdate OR vbrperdat LE new_date OR vbrp~erdat IN s_erdat ) " + JP 09 19 2011 Additional Optimization
    ORDER BY aubel aupos .
    ORDER BY aubel aupos matnr.
    """" This where i need your help Sir\Mam\Gurus
    it3_vbrp_details = it_vbrp_details.
    SORT it3_vbrp_details BY aubel matnr fkimg kzwi1 kzwi2 kzwi3 kzwi4 kzwi5 kzwi6 aupos vbeln
    mvgr1 mvgr2 mvgr3 mvgr4 mvgr5 knuma_pi knuma_ag mwsbp vkaus fkart belnr vbtyp kunag fksto.
    LOOP AT it3_vbrp_details INTO ls_vbrp_details.
    COLLECT ls_vbrp_details INTO itfinal1_vbrp_details.
    APPEND ls_vbrp_details TO it_vbrp_details.
    ENDLOOP.
    kzwi1,kzwi2,kzwi3 is also been sum up
    Sir the output is something like this
    Sales Ord# Material Qty KWIZ1 KWIZ2 KWIZ3 MGVR1 VBELN
    1234       Mat1     24  23.2  22    12           LastInvoice#
    1234       Mat2     12  20.0  21    15           LastInvoice#  
    1234       Mat3     37  22.0  22    16           LastInvoice#
    5432       Mat1     30  25.0  23    15           LastInvoice#
    5432       Mat2     24  22.0  24    23           LastInvoice#
    5432       Mat3     20  18.0  20    12           LastInvoice#
    Hope you can help me as i cant hardy sleep thinking of this ...
    I will really appreciate your great help..
    Thanks !
    I will really appreciate your great help..
    Thanks !
    Moderator message: duplicate post locked.
    Edited by: Thomas Zloch on Sep 20, 2011 3:05 PM

    Hi,
      How you want to display the output?..
    If you want to display the output as mentioned below, then you have to use nested loop & dynamic field assignments to get result.
    Output column
    sales order     Mat1 Mat2 Mat3 ......
    1234               24    12     37
    Kindly let me know, if you have any questions
    Regards,
    S.Senthilkumar

  • How to SUM two count(*) values in a single sql tatement?

    How can I get a single SQL statement to sum two values from a count(*)
    I want something like this:
    SELECT COUNT(*) FROM MYTABLE
    UNION
    SELECT COUNT(*) FROM MYOTHERTABLE;
    but instead of getting
    111
    222
    I want to see the sum of the two values.
    333can such a thing be done with one statement. I know I can do stuff inside a BEGIN END and have vars but wonder if there is simple single statement solution.
    Thanks in advance,
    David Miller

    SQL> select count(*) from user_indexes;
                COUNT(*)
                      30
    SQL> select count(*) from user_tables;
                COUNT(*)
                      43
    SQL> select (select count(*) from user_indexes) + (select count(*) from user_tables)
      2  from dual;
    (SELECTCOUNT(*)FROMUSER_INDEXES)+(SELECTCOUNT(*)FROMUSER_TABLES)
                                                                  73

  • How to sum a specific category in pop up menu?

    For my expences i use a pop up menu
    how can i make a cell that will only add the numbers under ( eg. grocery )
    Thank you

    Trad,
    The function SUMIF was designed to do what you are asking.
    SUMIF
    The SUMIF function returns the sum of a collection of numbers, including only numbers that satisfy a specified condition.
    SUMIF(test-values, condition, sum-values)
    test-values:  The collection containing the values to be tested. test-values is a collection containing any value type.
    condition:  An expression that results in a logical TRUE or FALSE. condition is an expression that can contain anything as long as the result from comparing condition to a value in test-values can be expressed as a Boolean value of TRUE or FALSE.
    sum-values:  An optional collection containing the numbers to be summed. sum- values is a collection containing number, date/time, or duration values. It should have the same dimensions as test-values.
    Regards,
    Jerry

  • Can't figure out how to sum only certain dates

    Hi all,
    Here is my issue: we use numbers to keep a running inventory of pieces in stock, and when a piece sells we mark it with the date sold. I'd love to be able to get a sum of monthly sales, but I can't figure it out. Would someone be kind enough to explain it to me like I was five? Here is a sample of our spreadsheet layout: http://i.imgur.com/sV1RU4s.png
    I can easily get a sum for the full column of C, but how do I enter the formula to sum only the sales from April, for instance.
    Thanks!!

    you can get function descriptions from Apple for free by downloading the function references here:
    http://support.apple.com/manuals/#productivitysoftware
    you will want to download the formula and function reference.
    OK...
    sumif() is a function that will sum values in a range based on a condition
    sumifs() is a similar function where multiple conditions
    both functions look at each row and only sum the values in a particular row when the condition(s) are all met.
    =SUMIFS(B,C,">="&E2,C,"<="&EOMONTH(E2, 0))
    let's work from the inside out...
    EOMONTH() returns the last day of the month you pass if offset by some number of months.  In this case I asked it to give the last day of the same month I passed in so the offset is 0.  The month I passed in is stored in E2.
    the basic concept is I only want to sum values in column B when the date in column C is in a paricular month.  said another way... I want to sum values in B where the corresponding date (in the same row) of column C is greater than or equal to the 1st day of the month AND is it also less than or equal to the last to of the month.
    SUMIFS() has several arguments a range to sum followed by a pair of arguments (test values range and a condition):
    SUMIFS(<SUM_RANGE>, <TEST_RANGE1>, <CONDITION1>, <TEST_RANGE2>, <CONDITION2>, etc )
    the sum range is column B
    test range 1 is the date column (column C)
    the condition is ">="&E1  which concatenates ">=" with the date in cell E1 to make a condition ">=Jan 1, 2013"
    test range 2 is the date column (column C)
    the condition is "<="&EOMONTH(E1, 0)  which concatenates "<=" with the date corresponding to the last day of the monthe in cell E1 to make a condition "<=Jan 31, 2013"
    I hope this helps

  • 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

  • How to Sum in a SAP Query

    Folks,
    I have given up....Really need some advice....
    I need a report example: Order Number, Order Type, Order Date, Customer number, Net Price, Total order cost
    I can get all I need from file VBAK, EXCEPT total order cost, which is at the line level (VBAP).  Now I need to show one line per order and sum the cost field (VBAP/WAVWR)...
    How can I accomplish this in SAP Query?  IS this even possible?

    Hi,
    I am sure about SAP Query...
    But check this program which might satisfy your requirement..
    Declarations.
    TYPE-POOLS: slis.
    DATA: BEGIN OF wa_data,
            vbeln LIKE vbak-vbeln,
            auart LIKE vbak-auart,
            audat LIKE vbak-audat,
            kunnr LIKE vbak-kunnr,
            netwr LIKE vbak-netwr,
            wavwr LIKE vbap-wavwr,
            waerk LIKE vbak-waerk,
            posnr LIKE vbap-posnr,
          END OF wa_data.
    DATA: itab LIKE wa_data OCCURS 0 WITH HEADER LINE.
    DATA: itab_final LIKE wa_data OCCURS 0 WITH HEADER LINE.
    DATA: v_tabix TYPE sytabix.
    DATA: t_fieldcat TYPE slis_t_fieldcat_alv.
    Selection-screen.
    PARAMETERS: p_erdat LIKE vbak-erdat OBLIGATORY.
    START-OF-SELECTION.
    Get the data
      SELECT avbeln aauart
             aaudat akunnr
             anetwr bwavwr
             awaerk bposnr
             INTO TABLE itab
             FROM vbak AS a INNER JOIN vbap AS b
             ON avbeln = bvbeln
             WHERE a~erdat = p_erdat.
      IF sy-subrc <> 0.
        MESSAGE s208(00) WITH 'No data found'.
        LEAVE LIST-PROCESSING.
      ENDIF.
      SORT itab BY vbeln.
    Sum the cost.
      LOOP AT itab.
    Store the tabix.
        v_tabix = sy-tabix.
        wa_data = itab.
        AT END OF vbeln.
          SUM.
    modify the cost.
          MOVE wa_data TO itab_final.
          MOVE itab-wavwr TO itab_final-wavwr.
          APPEND itab_final.
          CLEAR itab_final.
        ENDAT.
      ENDLOOP.
    SHow the report.
      DATA: v_repid TYPE syrepid.
      v_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                i_program_name     = v_repid
                i_internal_tabname = 'WA_DATA'
                i_inclname         = v_repid
           CHANGING
                ct_fieldcat        = t_fieldcat.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                i_callback_program = v_repid
                it_fieldcat        = t_fieldcat
           TABLES
                t_outtab           = itab_final.
    Thanks,
    Naren

  • How to sum space delimited hex values in a string, and do other stuff?

    Hello
    I am trying to write a Bourne shell script that takes a non-constant-length character string as input, converts each character to hexidecimal value, sums each value, takes the two's complement of the sum, logically ANDS it with FF, and if any of the resultant "nibbles" are a-f, print/save that nibble as A-F, for later display as a two-character-long character string
    For example, assume a variable (as in non-constant) length variable $A
    A="w04:0;2"
    the road that I started down was to define
    B=$( echo $A | od -An -t x1 -N"${#A}" )
    # for this example, $B=77 30 34 3a 30 3b 32
    It's the middle part where I need some magic. What I want to do is add the whitespace-delimited hex values of this string, for this example
    C=77+30+34+3a+30+3b+32
    so for this example, $C=1b2
    then take two's complement of $C; for this example, $TWOS_COMP=ffff ffff ffff ffe4e
    and logically AND it with FF; for this example, almost-final answer is 4e
    then save final result as uppercase character string variable (for this example, variable's contents would be 4E)
    Is what I'm trying to do intuitively obvious to any of you gurus out there, that could rattle off an answer? I'm okay with trashing my approach thus far and trying something totally different, within the constraint that it run inside a Bourne shell script.
    Thanx in advance, if anybody can help!

    I've made progress. I've converted each character of a non-constant-length string $A into a space-delimited string of hex values, added them up, and retained the least significant byte (i.e., the 8 least significant bits). Here's how:
    B=$( echo $A | od -An -t x1 -N"${#A}" )
    D=0
    for C in $B; do
      C=0x$C
      D=$(($D + $C))
    done
    D=$(($D & 16#FF))
    D=`echo "ibase=10;obase=16;$D" | bc`
    The missing piece now is how to take the two's complement of $D. Anybody out there with any ideas on how to handle the two's complement piece inside a Bourne shell?
    Thanx

Maybe you are looking for

  • My iPod can't be read from or written to

    Having finally got through the rigmaroles of set up and iTunes, I have tried on a number of occasions to synchronise my new ipod nano 4gb. It manages to download/sync about 26 tracks then comes up with an error message "Attempting to copy to the disk

  • Customer payment  due date

    i want to calculate customer due date based on payment terms and print in to my invoice output, which fields and table do need to take consideration, would anyone help me on that thanks Points would be rewarded

  • Problem restoring iPad from icloud

    I install the iOS 7 in my iPhone 4S during the restore from icloud of my iPad air (ios6). Now can't back-up the iPhone nor restore or install the ios7 in the iPad. How can I solve this problem?

  • Connecting the sound to my laptop

    i don't have any sound on my laptop how do i get this

  • Fill the 'Objects and Attachments ' in Decision step with milestone detils

    My requirement is to fill the 'Objects and Attachments ' in Decision step with a display milestone details as seen in cj20n transactiobn. I am using business object MLST_NETW but display method does not show detsils of milestone . is there any other