Calculating the sum based on condition

Hello Everybody,
I am currently working on a report, where i have to calculate sum on transaction amount for all account numbers. Below is the example of data.
masteraccount        accountno      transaction amount
1001                        001                  50000000
1001                        002                  50000000
1001                        003                  50000000
1002                        004                  98765
1002                        005                  98765
here i have to calculate the sum of transaction amount based on distinct master account.
Thansk
Ram

create a group for master account
use manual running totals.
RESET
The reset formula is placed in a group header report header to reset the summary to zero for each unique record it groups by.
whileprintingrecords;
Numbervar  X := 0;
CALCULATION
The calculation is placed adjacent to the field or formula that is being calculated.
(if there are duplicate values; create a group on the field that is being calculated on. If there are not duplicate records, the detail section is used.
whileprintingrecords;
Numbervar  X := x + ; ( or formula)
DISPLAY
The display is the sum of what is being calculated. This is placed in a group, page or report footer. (generally placed in the group footer of the group header where the reset is placed.)
whileprintingrecords;          
Numbervar  X;                         
X

Similar Messages

  • Calculate SUM based in condition in iTAB

    Hi all,
    I have the ITAB as follows.
    wa_mseg-mblnr = '5000000130'.
    wa_mseg-mjahr = '2008'.
    wa_mseg-bwart = '901'.
    wa_mseg-dmbtr = '00000005000'.
    wa_mseg-bpmng = '00000000100'.
    wa_mseg-ebeln = '1059200855'.
    wa_mseg-ebelp = '00010'.
    APPEND wa_mseg to itab_mseg.
    wa_mseg-mblnr = '5000000131'.
    wa_mseg-mjahr = '2008'.
    wa_mseg-bwart = '902'.
    wa_mseg-dmbtr = '00000002500'.
    wa_mseg-bpmng = '00000000050'.
    wa_mseg-ebeln = '1059200855'.
    wa_mseg-ebelp = '00010'.
    APPEND wa_mseg to itab_mseg.
    wa_mseg-mblnr = '5000000132'.
    wa_mseg-mjahr = '2008'.
    wa_mseg-bwart = '901'.
    wa_mseg-dmbtr = '00000002500'.
    wa_mseg-bpmng = '00000000050'.
    wa_mseg-ebeln = '1059200855'.
    wa_mseg-ebelp = '00010'.
    APPEND wa_mseg to itab_mseg.
    now i want to add the BPMNG for the BWART = 901
                                   DMBTR   for the BWART = 901
    ans same thing  for the BWART = 902.
    how do i calculate the SUM based on condition.

    now i want to add the BPMNG for the BWART = 901
    DMBTR for the BWART = 901
    ans same thing for the BWART = 902.
    how do i calculate the SUM based on condition.
    Hi, you can loop de internal table and do a control cut by "bwart". For doing that the order of the fields of your internal table must change.
    If you have:
    1st.mblnr
    2nd.mjahr
    3rd.bwart
    you have to change to:
    1st.bwart
    2nd.mblnr
    3rd.mjahr
    So in the loop you will can do like this.
    loop at itab.
    aux_sum = itab-BPMNG + aux_sum.
    at end of bwart.
    * Here you will have de SUM for BWART.
    * Then you clear aux_sum for the next different BWART.
    endat.
    endloop.
    hope this help you.
    Andrew83

  • How can hide the buttons based on condition

    Dear all
    I have to hide the button based on condition
    When I open the third page directly I want to hide that button
    When I open the third page via first and second page I need to visible that button
    I pass spell parameter from first to second and second to third
    In third page I get the value using pagecontext
    I write the code in third page co
    If I go directly third page it is null
    If I go to third page via first the value is Y
    If(“Y”.equals(pmode))
    OASubmitButtonBean btn =( OASubmitButtonBean )webBean.findChildRecursive(“<id>”);
    If(!btn=null)
    btn.setrendered(true);
    else
    btn.setrendered(false);
    but the button is not hiding
    Regards
    Sreekanth

    Hi Srikanth,
    I have modified ur method:
    OASubmitButtonBean btn =( OASubmitButtonBean )webBean.findChildRecursive(“<id>”);
    If(btn !=null)
         If(“Y”.equals(pmode))
         btn.setrendered(true);
         else
              btn.setrendered(false);
    Thanks,
    'Kumar
    Edited by: Kumar Kovela on Aug 3, 2009 5:53 AM

  • Sum % based statistical conditions as %

    I am having some difficulty figuring out the following pricing requirement
    I have two condition types, ZPC1, ZPC2.  Both of these are % based discounts and are statistical. 
    I want to create a subtotal that sums these two conditions up as a percentage so if ZPC1 = 1% and ZPC2 = 2%, I want a line in the price procedure to say "Total Discounts Available"  3% and then the condition value is 3% x gross price. 
    When i create the subtotal, its is being converted to $/cs calculation instead of %.  How do i get the subtotal to be calculation type = V.  Note:   this line is just informational to the end user...i do not want to create a separate condition type for the subtotal.

    Hi,
    I assume that both of your '%' Discount Condition types which are statistical are w.r.t Sales Price Condition Type.
    You can add both the conditions and get the value at Subtotal.
    This will not give you the Condition Amount Total but it will give you the Condition Value Total.
    now this Subtotal value you can post though the new 'ZDIS' Condition type with 100%.
    e.g ;                                                                       Stat
    10    Pr00  
    15    ZDIS1  10                                                      x
    20    ZDIS2  10                                                      x
    25    SubTotal    15 20
    30    ZDIS           25
    I hope this could help you resolve.
    Thank You.
    RB.

  • How to find the Sum based on Like Dates

    Hello everyone,
    Column 1 contains "Date Sent", Column 2 contains "Dates of Service" and Column 3 contains the payment "Amount" in USD. I want to write a formula that will total up the sum of payment values from column 3 based on the date of payment (Column 1).
    Thanks!
    Jared

    Hi Jared,
    This will do what's illustrated in your example, but has a few restrictions:
    The dates must run in ascending order.
    To get a total for the last date, a later date (with no corresponding amount) must be entered after the last transaction.
    Formula:
    Entered in D2, and filled down the rest of column D:
    =IFERROR(IF(A3>A2,SUMIF($A,A2,C),""),"")
    IFERROR is used to suppress the error message that arises from the formula in D10 referencing a cell in D11.
    Regards,
    Barry

  • How to find the sum based on two variables

    Hello!
    I have just started using Numbers, I have a spreadsheet which lists a number of transactions.
    On my chart I have Columns "Date", "Memo", "Type", and "Amount".
    The Type column is a drop down list. What I want to do and find the sum for transactions that fall between a date range (i.e. months 1-3) and that match a certain "Type". I can figure out how to use the sumif function to find the sum for a date range, however I cant figure out how then to only sum only those that match a type.
    Any help?

    Brendon,
    This question arises from time to time in different situations. The answer is to first create an auxiliary column which calculates whether or not your multiple conditions have been met. In this case you have three - more than or equal a start date, less than or equal an end date, and a "Type".
    I'm assuming that your dates and "type" are flexible, so an extra table to enter your search data is shown below, but these three cells could be incorporated in your main table. The formula for the auxiliary column is:
    =IF(AND(Date>=Search Range :: A$2,Date<=Search Range :: B$2,Type=Search Range :: C$2),"SUM","")
    All rows with the word "SUM" satisfy the three conditions. The footer row contains the sum of the values meeting the desired conditions using:
    =SUMIF(Aux, “SUM”, Amount)
    Obviously this has to be reworked to your situation, but the auxiliary column is the key.
    pw
    Message was edited by: pw1840

  • Suppressing a segment in the target based on condition

    Hi Guys,
       Iam working on an interface which has a requirement in which we need to suppress the segment in the target XML file of the IDOC Structure, Based on the data coming from a particular field in the Source IDOC iam doing a java lookup, if the condition fails in the lookup it should suppress the segment in the target XML file of the IDOC.The occurance of the particular segment in the IDOC is 0 to 999999.
    Kindly throw some light on the procedure in which this can be acheived.
    Any sort of suggestions regarding this are appreciated.
    Thanks in Advance.
    Praveen.

    May be it help you:
    (not so trivial solution)
    Try to create Advanced User-Defined function (in mapping designer) with at least 2 parameters. (first - this segment, second - particular field) (check "Cache entire queue" option)
      something like this:
    public void Suppress(String[] a, String[] b, ResultList result, Container container){
        String segment = a[0];
        for(int i=0; i < b.length; i++) {
           String data = b<i>;
           if(data != null and data.equals('race conditions')) {
             result.addValue(segment);
             break;
           }else {
             //ignore.
             //note: for empty segment - result.addSuppress()

  • Regarding Suppressing the Idoc based on Condition

    Hi All,
    Its File to Idoc one, Here is the logic,
    If Status code = X1 or AB then only create the Idoc AND also create the one one Idoc for each and every line item
    If we have 2 line items from text file, we have to create 2 idocs in ECC.
    We setup in the following way....
    To create the Multiple Idocs for multiple Line items, i changed the IDOC segment Occurence to 0-9999 and Idocs are getting posting correctly.
    The thing is if the status code is either X1 or AB then it is getting creating idocs as per the logic. If the status code is not either one means it is failing in XI MONI.
    please advice me i shld not see the failed message in MONI
    Regards
    Vamsi

    Hi Vamsi,
    If you donot want to generate the IDOC when the Status Code is not X1 or AB, either use create function as mentioned by Raj or also craete a dummy receiver in ID and use conditions in receiver determination and route the data as per the status code.
    If Status Code = X1 or AB                       receiver= idoc
    If Status Code != X1 or AB                      receiver= dummy receiver
    I hope this is helpful.
    Regards,
    Sarvesh Desai

  • Color the row based on condition

    Hello all,
    I am woring on an interactive adobe form being called by a web dynpro application.
    The adobe form interface used is XML Schema based. The form displays some data at header level and item level.
    The item details are displayed in a table. Now. my requirement is that i have a field 'STATUS'  in the item table. I want to display the row with RED color if the STATUS = 'X' . How can i achieve this.. i tried using java script at Row initialze event but that didn' work.
    Please let me know if you have some solutions.
    Thanks & Regards,
    Ravi Aswani

    Try this code
    var fields = xfa.layout.pageContent(xfa.layout.page(this)-1, "field", 0);
    var custordertext;
    for (var i=0; i <= fields.length-1; i++)
         if (fields.item(i).name == "STATUS")
              if(fields.item(i).rawValue == "X")
                              this.fillColor = "50, 50, 255";
    use this event in calculate event
    Thanks,
    Rakesh

  • Formula to Copy all the values based on condition

    Hi All,
          I have Text Column called "PASS" in Pivot table holding values like and NA and 0.0133333333333333 .
          So I want to create the calculate column "CALS "and copy all the values which are not holding NA into this column and set value 0 if found NA.Can any one help me how can I solve this.
    Thanks,
    Sid

    Hello Sid,
    For this you can use a calculate column a simple condition with the IF function like
    =IF(MyTable[MixedValueColumn] = "NA", 0, CURRENCY(MyTable[MixedValueColumn]))
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • To disable  fields on the screen based on condition

    Hello folks,
    Iam doing  one module pool program in that in one screen i need to disable the 3 fields based on the value entered in the 1st field.
    for me its working but  after entering the value in field 1
    I need to press enter key then only it is working.
    is it possible to gray those 3 fields just by entering values and without pressing the enter key.
    any suggestion will be rewarded
    Regards,
    cnu

    Hi,
    It is not possible to gray field without pressing enter  key.
    Because a key is pressed it will trigger an event ..i.e PAI .
    So if we dont press enter .System will not do anything.cause it does not know which event to trigger..
    So we have to press enter
    Best regards,
    Brijesh

  • SQL query and Delete the data based on condition

    Hi All,
    I have one requirement like I need to fetch the data from the table, In that table one filed (XXXXX) domain type is STAMP.
    delete the data if the sy-datum ( length 8) is greater than field XXXXX  which has length 14.
    Please suggest me how to delete or fetch the data with the same length.
    I have used below code..but did not work..
    "Concatenate sy-datum '%'  into gv_var1.
    select *
       from DD03l
       into itab
    where XXXX like gv_var1."
    and tried this one as well
    1. DELETE itab WHERE XXXXX GT sy-datum.
    2. DELETE itab WHERE XXXXX GT gv_var1.

    Hi,
    When dates are in different formats you have to always convert them into one common format and then do the checks. Its better to convert the date in the variable into timestamp(using CONVERT DATE statement-look for abapdocu for its usage) and then compare it with the date on database.
    data: gv_var1  TYPE timestamp.
    convert date sy-datum into time stamp gv_var1.
    select *
    from DD03l
    into itab
    where XXXX like gv_var1.
    should work now.
    Hope this helps.
    Shwetha

  • When i park a document in FV60 i should get the messages based on conditions;

    Hi All,
    In FV60 when amount and amount in doc currency is not equal and if i park it should through as error message as 'Posting is possible with Zero balance',i have done this and it is working.
    now when amount and amount in doc currency is equal means 'zero' it should succesfully park the document,but i am getting same error message as above.
    Can any one please helpme out how to solve this.
    Thanks,
    Ram

    Hi,
    do you really think someone could guess with the poor informations you give ??
    regards
    Fred

  • Select the record based count condition

    Hi Experts
    I have a table with columns  StateDate,State,Name & Type . For the same date there could be 2 or more rows for the same name .
    I need to retrieve the data from the table only for the name containing single row in the table and state = 'On'
    Please find the Create & Insert Scripts below . Am assuming it needs to be done with a window function and am not yet comfortable with window function .
    CREATE TABLE ItemState
    (StateDate Date,
    State Varchar(3),
    Name Varchar(3),
    Type int)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','Off','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','ABC',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','Off','CBR',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','On','CBR',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','On','XYZ',1)
    Expected Result
    StateDate
    State
    Name
    Type
    3/11/2014
    ON
    ABC
    1
    3/12/2014
    ON
    XYZ
    1
    Kindly help
    Thanks
    Priya

    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','Off','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','ABC',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','Off','CBR',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','On','CBR',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','On','XYZ',1)
    again adding this 3 rows 
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','Off','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','ABC',1)
    SELECT *
    FROM   itemstate order by statedate, name,state
    2014-03-11 On
    ABC 1
    2014-03-11 On
    ABC 1
    2014-03-11 Off
    XYZ 1
    2014-03-11 Off
    XYZ 1
    2014-03-11 On
    XYZ 1
    2014-03-11 On
    XYZ 1
    2014-03-12 Off
    CBR 1
    2014-03-12 On
    CBR 1
    2014-03-12 On
    XYZ 1
    so only xyz on 2014-03-12 will qualify
    WITH test
         AS (SELECT *,
                    row_number()
                      OVER (
                        partition BY statedate, name
                        ORDER BY state ASC) rnasc, 
    count(state)
                      OVER (
                        partition BY statedate, name
                        ORDER BY state desc) rncount
             FROM   itemstate)
    SELECT *
    FROM   test t1  where rnasc = 1 
    and state = 'on' and rncount = 1
    Amish shah
    http://bloq.sqltechie.com

  • PM Reports: Need to find the sum of a particular field in the output.

    Hello Experts,
                          I have an issue. I have developed the report to calculate the power per ton. It is PM module.
    Input is : DATE & Measuring Point.
    Output required is : For a particular date , What is the power consumed per ton.
    Its is calculated by the formula Power consumed per day /  Production.
    I have multiple entries for production ( because different material are used )  per date and a single entery for power (because power is taken as total power consumed per day)
    Hence im getting the output as
    For example:
    date                power            production         power/ton
    01.03.2011      5000                    100                  50.00
    01.03.2011      5000                      50                 100.00
    01.03.2011      5000                      25                 200.00
    01.03.2011      5000                      75                  66.66
    The desired result is
    date                power            production         power/ton
    01.03.2011      5000                    250                  20.00
    I need to sum the production field.
    How can I achieve this ?
    Please help.

    Hello
    Rotate the loop and use event so on change just clear the variable based date condition .
    take 2  temp variable for summation
    clearing the total and moving value on permanent variable means modifying the itab.
    loop at .
    *Clear
    on change <datefield>.
    modify itab from wa  transporting <field name> .
    clear <total field>.
    endon.
    *Total
    t_prd  = t_prd + production..
    t_power = t_power + power .
    endloop.

Maybe you are looking for