Sum calculation

Hi Experts,
Please advice,
I am having three fields in output 1 is directly fetched from table and other two are variables.
ITAB-MENGE  = fetched data.
ITAB-UCOMM = input on ( user command )
when the user press ENTER
ITAB-SUM = ITAB-MENGE  +  ITAB-UCOMM.
For eq:
Suppose if  ITAB-MENGE  which is fetched from table   =   100
and if the user enters the value in ITAB-UCOMM   =   200 
and when the user press enter the sum should display on the other field ITAB-SUM
Note: I am using normal write statement ( not ALV )  & there is no need of saving option.
Thanks
R.Karthik

Hi karthik,
Your query is ambiguous. Still I am answering as per my understanding.
Let say you are selecting MENGE from database table.
And you have UCOMM as parameter in selection screen.
So if ITAB has following values,
100
200
300
400
and UCOMM = 20
then
data : begin of itab occurs 0,
             menge type menge,
             tot(10) type c ,
         end of itab.
***already you selcetd data in ITAB
loop at itab.
  itab-tot = itab-menge + p_ucomm.
  modify itab transporting tot.
endloop.
Hope this helps you.
Regards,
Anil

Similar Messages

  • I am using Numbers on my iPhone5 and cannot get the app to do a simple (SUM) calculation.  It shows the formula correctly in the cell, but all I get for my long list of numbers to add is 0.  How can I get this to work?

    I am using Numbers on my iPhone5 and cannot get the app to do a simple (SUM) calculation.  It shows the formula correctly in the cell, but all I get for my long list of numbers to add is 0.  How can I get this to work?

    Oaky, at least we got that far.  Next step is to determine if all those "numbers" are really numbers.  Changing the format to "number" doesn't necessarily change the string to a number. The string has to be in the form of a number.  Some may appear to you and me as numbers but will not turn into "numbers" when you change the formatting from Text to Number. Unless you've manually formatted the cells to be right justified, one way to tell if it is text or a number is the justification. Text will be justified to the left, numbers will be justified to the right.
    Here are some that will remain as strings:
    +123
    123 with a space after it.
    .123

  • Totalling rows that have a 'sum' calculation in them

    I would like to report a single row for each 'cardcode' (I know there is only one at the moment) but as each row already has a 'sum' calculation in it I am not sure how to do this, any ideas please?
    The idea is to report only a total sales value per customer on one row for the given time period
    SELECT
    t1.cardcode as 'Code',
    t1.cardname as 'Name',
    t1.docnum as 'Document Number',
    sum(t0.price) as 'Sales Value'
    FROM
    rdr1 t0
    inner join ordr t1 on t0.docentry = t1.docentry
    WHERE
    t1.docdate >= '[%0]' and
    t1.docdate <= '[%1]' and
    t1.cardcode = 'ALL006'
    GROUP BY
    t1.cardcode,
    t1.cardname,
    t1.docnum
    Thanks,
    Robin

    Hi Robin,
    try this one. Instead of OINV you also can use ORDR:
    SELECT T1.[CardCode], T1.[CardName], SUM(T1.[DocTotal]-T1.[VatSum]) AS 'Sales Value'
    FROM [dbo].[OINV]  T1
    WHERE T1.[DocDate] BETWEEN [%1] AND [%2]
    GROUP BY T1.[CardCode], T1.[CardName]
    Of course, you will find a standard report in the Sales / Reports. There you can display sales value for customers on a given date range. Why do you want to create a query?
    Regards Steffen

  • How to avoid duplications making a SUM calculated field

    Hi, I'm trying to resolve this problem;
    In my dataset (in a custom folder on the administrator) I have a list of tickets (with some attributes), and some of them are duplicated:
    For example
    Ticket_id     Group_id             Ticket_date                Resource_name          Ticket_status      
    5416          100000401       10/12/2007 7:10:31 am                Mr. A                 2
    5416          100000401       9/1/2008 11:00:44 pm                 Mr. A                 2
    57381         100000401       27/12/2007 11:37:11 am               Mr. A                 2
    57381         100000401       15/1/2008 9:33:12 am                 Mr. A                 2
    I want this duplication because I need it when I filter the dataset (using the Ticket_date) with two parameters:
    Ticket_date between lower_limit_date and upper_limit_date
    So, inside the report, regarding the ticket's number, if I take 2 records with the same ticket_id, I have a calculated field where I use the COUNT_DISTINCT and for each couple of tickets the count is always =1; in this way (inside the report) I have the following fields:
    Group_id           Count_tickects   Resource_name  
    100000401              2                    Mr. A                 This is OK !
    Now, if I want to count how many tickets have the status = 2 (it means they are closed), I want to obtain 2 and NOT 4
    I tried to use this calculation (Tickets Closed): SUM(CASE WHEN "Tickets Report #7 COMPL".Ticket Status Id = 2 THEN 1 ELSE 0 END)
    but I always had the result of 4...and this not correct, because the tickets are only 2...
    I also tried to use some analytic function using the OVER PARTITION BY, but I didn't obtain the correct result
    In other words I'd like to achieve this:
    Group_id           Count_tickects   Tickets Closed     Resource_name
    100000401              2                     2             Mr.AAny help will be appreciated
    Alex

    Hi Rod, thanks for the reply,
    I tried this calculation
    COUNT_DISTINCT(CASE WHEN "Tickets Report #7 COMPL".Incident Status Id = 2 THEN 1 ELSE 0 END)
    but it retrieves 1; it's right, because the result of the CASE statement is always 2 (the Ticket_status is always 2, 4 times), but this is not what I expect.
    I'd like to calculate how many tickets are effectively opened (Ticket_status = 2) and this result is *2*, because I have only 2 ticket_id (5416 and 57381); the problem is that inside the data set these two ticket_id's are repeated two times.
    I can't use "Hide Duplicate Rows" because this is only a layout solution (behind I have always the duplication); I can't use more than one aggregate function together because I have the error: Nested aggregate functions are not allowed...
    To resolve this problem, I think, I have to restrict the records which are processed by the CASE statement; instead of pass to the calculation all four records (twice the ticket_id 5416 and twice the ticket_id 57381) I have to pass only two records (one the ticket_id 5416 and once the ticket_id 57381).....but how....???
    Alex

  • Trouble when attempting to Sum Calculated Field.

    I had to create a calculated field called RI_Limit which contains static data.  (Developers/DBA could not enter it into the database at this time, so this was a work around. 
    The calculated field is setup as such:
    =iif(Fields!Location_LOCATION_NAME.Value = "a", 8, iif(Fields!Location_LOCATION_NAME.Value = "b",2, iif(Fields!Location_LOCATION_NAME.Value = "c",0, iif(Fields!Location_LOCATION_NAME.Value = "d",0, iif(Fields!Location_LOCATION_NAME.Value = "e",1, iif(Fields!Location_LOCATION_NAME.Value = "f",1, iif(Fields!Location_LOCATION_NAME.Value = "g ",0, iif(Fields!Location_LOCATION_NAME.Value = "h",0,iif(Fields!Location_LOCATION_NAME.Value = "i",4,iif(Fields!Location_LOCATION_NAME.Value = "j A",0,iif(Fields!Location_LOCATION_NAME.Value = "k",0,iif(Fields!Location_LOCATION_NAME.Value = "l",7,iif(Fields!Location_LOCATION_NAME.Value = "m",0,iif(Fields!Location_LOCATION_NAME.Value = "n", 1, iif(Fields!Location_LOCATION_NAME.Value = "o",0, iif(Fields!Location_LOCATION_NAME.Value = "p",1, iif(Fields!Location_LOCATION_NAME.Value = "q",3, iif(Fields!Location_LOCATION_NAME.Value = "r",1, iif(Fields!Location_LOCATION_NAME.Value = "s",1, iif(Fields!Location_LOCATION_NAME.Value = "t",3, iif(Fields!Location_LOCATION_NAME.Value = "u",5,iif(Fields!Location_LOCATION_NAME.Value = "v",0,iif(Fields!Location_LOCATION_NAME.Value = "w",0,"NA")))))))))))))))))))))))
    and I setup a textbox with that expression and the numbers fill in correctly with its cooresponding site name.
    However, when I go to sub total or total, I get a much larger number than expected. (See screenshot)
    I have searched the internet on a way to calculate both the total by Location Level 2 and LOB total, but nothing that pertains to the specific issue where by calculated field contains static data.  Nothing I try produces an accurate sum.  Any suggestions?

    Hi Katherine,
    Sorry for taking a few days to reply.
    I tried the suggestion, but it it still not summing my calculated fields.  The total row will calculate my other cells okay but not the calculated fields that I had to add to the report.  When I attempted to write an expression to sum the calculated
    fields I get the following error message. 
    The expression used for the calculated field '=sum(iif(Fields!Location_LOCATION_NAME.Value = "test", 8, iif(Fields!Location_LOCATION_NAME.Value = "test1",2, iif(Fields!Location_LOCATION_NAME.Value = "test2",0, iif(Fields!Location_LOCATION_NAME.Value = "test3",0, iif(Fields!Location_LOCATION_NAME.Value = "test4",1, iif(Fields!Location_LOCATION_NAME.Value = "test5",1, iif(Fields!Location_LOCATION_NAME.Value = "test6 ",0, Fields!Location_LOCATION_NAME.Value = "test7",0,Fields!Location_LOCATION_NAME.Value = "test8",4,Fields!Location_LOCATION_NAME.Value = "test9",0,Fields!Location_LOCATION_NAME.Value = "test10",0,Fields!Location_LOCATION_NAME.Value = "test11",7,Fields!Location_LOCATION_NAME.Value = "test12",0,Fields!))' includes an aggregate, RowNumber, RunningValue, Previous or lookup function. Aggregate, RowNumber, RunningValue, Previous and lookup functions cannot be used in calculated field expressions.
    The Espression for the calculated field I am attempting to sum is the following:

  • Using a "Sum" Calculated Field on a "Count" query column?

    Here's my query using the Query Report Builder:
    SELECT Col1, COUNT(Col1) AS Count_Column
    FROM Table
    GROUP BY Col1
    It generates a report that lists all the values of column
    "Col1" and how many times each value was used in Col1
    For instance, if Col1 contained the value 'A' 12 times, 'B' 6
    times, and 'C' 19 times, the report would generate this:
    A - 12
    B - 6
    C - 19
    What i need as a column footer is the total count of all the
    values, which in this case 12+6+19=37
    I am using a calculated field, setting the data type to
    Double, the calcuation to Sum, and the perform calculation on to
    'query.Count_Column'. Reset Field When is set to None.
    When I run the report, it doubles the last number in the
    report's Count column (19) and displays 38 on the page. I tested
    this with another column and it doubled the last number in the
    report as well.
    How can I get it to properly Sum my Count_Column?

    Hi,
    You need to check note 208366.1 which explains why totals can be blank. Without knowing the detail of you decode function it is hard to say what needs to be changed. Try putting a sum in front of the decode e.g.
    sum(decode(period, 'Jan period', value, 0))
    Hope that helps,
    Rod West

  • Sum calculated field in report

    Hi, I have a report that groups by employee then by machine. In this report I sum several fields, but need to sum a calculated field and can't figure it out. This is the calculation:
    <?( QTY_MOVED) div ( TIME +.001 ) div ( INVERSE + .001)?>
    This is a total field using a field that works fine.
    <?sum(current-group()/QTY_REJ)?>
    How do I incorporate the calculation in the <?sum(current-group()/.............I get errors if I just put in the calculation above.
    thanks!

    Thank you for your help. After taking your advice and getting it to work by messing around with the brackets, management has changed their mind on the calc. Now they want me to use this calculation:
    SELECT EMPLOYEE, SUM(QTY_MOVED), SUM(QTY_REJ), SUM(TIME), (nvl([b]sum(QTY_MOVED),0)/nvl(sum(TIME),0))/nvl(sum(INVERSE),0) eff ,'DIRECT'
    FROM VW_TIMETRACK
    WHERE START_DATE >= :BEGIN
    AND START_DATE <= :END
    AND WORK_ORDER <> ' '
    GROUP BY EMPLOYEE
    to get the average. Now the weird thing is, I can get the value in toad, and I can get it to output in raw xml data, but when I try to add the eff field right next to the sum(time) field in the word form, nothing shows up. Absolutely no data. But it is in the xml. I'm using <?sum(current-group()/EFF)?> , just like I am for <?sum(current-group()/TIME)?> . I've made it text, numeric, decimal. Nothing is coming out.

  • Trailing sum calculation in ASO

    Hi All,
    I need to calculate 12 months trailing revenue in a ASO cube. I started working on the member formula and this is what i have for calculating it within one scenario and it is working fine.
    SUM(TAIL(TUPLERANGE(
    ([ACCOUNT].[REVENUE],[SCENARIO].CurrentMember,Lag([YEAR].CurrentMember,1,LEVEL),[PERIOD].CurrentMember),
    ([ACCOUNT].[REVENUE],[SCENARIO].CurrentMember,[YEAR].CurrentMember,[PERIOD].CurrentMember))
    ,12))
    However i need to cross scenario as the balance for some of the prior months will come from other scenario i.e. Actual. In order to acheive that i started to expand this formula like below using UNION
    SUM(TAIL(UNION (
    TUPLERANGE(([ACCOUNT].[REVENUE],[ACTUAL],Lag([YEAR].CurrentMember,1,LEVEL),[PERIOD].CurrentMember),([ACCOUNT].[REVENUE],[ACTUAL],[YEAR].CurrentMember,[PERIOD].CurrentMember)) ,
    TUPLERANGE(([ACCOUNT].[REVENUE],[SCENARIO].CurrentMember,[YEAR].CurrentMember,[JAN]),([ACCOUNT].[REVENUE],[SCENARIO].CurrentMember,[YEAR].CurrentMember,[PERIOD].CurrentMember))
    ),12))
    The idea was that i will create tuples for ACTUAL and current scenarios seprately and then i will combine them using UNION and select the last 12 tuples using TAIL. This formula gets verified but it just does not work. When i try to retreive this member, it terminates the application and creates the exception file.  Are there any limitations with UNION that may be resulting into this? or Is there something very basic i am not doing right here?
    Any help/suggestions
    Regards,
    Sunil

    Hi Tim, That is a good idea but may not work for the requirements i have. I provided very simplistic picture for easy explaination. My previous balance may come from number of scenarios [multiple forecasts] whichever business thinks reflects the best current state at that point in time. Eventually it is ACTUAL but that is towards the end of the cycle. We have built this flexibility using sub variables and that is what i was planning to use in this formula as well. 
    Regards,
    Sunil

  • Simple Sum Calculation in Forms

    I have a seriously simple situation, alas when I try to set it up, I am only able to select one field to calculate?  I am working in Adobe X.  I simply want to calculate the sum of 5 fields into a "Total" Text Field... 

    Hi miaff,
    I think this tutorial is exactly what you're looking for: http://acrobatusers.com/tutorials/how-do-i-use-basic-calculations-in-a-form
    Please let us know if you still have trouble!
    -David

  • Sum calculated data results from three queries in another query

    Hello,
      I would like to read calculated data from three different queries and sum them in another query.  Is it possible to do it, please?

    Hi there,
    We have done this in Excel with a debtors report. I have five queries, each on a different sheet in a workbook. I have their total line appearing at the top of the results area.
    Then I have an Excel worksheet with Excel formulas to bring through the totals on the other reports.
    i.e.   +Sheet1!C30      + Sheet2!C35     + Sheet3!D40    = Result
    Hope this helps,
    Regards
    Gill

  • SSAS Distinct Sum Calculation

    I have a fact table with repeated data like so:
    Deal ID LoanAmount
    1 100
    1 100
    2 200
    3 300
    By default, I set the aggregation for LoanAmount to be sum. This is giving me a result of 700. This is not what I want, I want to be able to sum on the Distinct ID. The correct result should be 600. I set the LoanAmount to the aggregate function Max and
    in a new calculated field I tried entering:  
    create currentcube.measures.SumAmount as
    Sum([Dimension Deal].[Deal ID], [Measures].[Loan Amount])
    However I keep receiving syntax errors? Is there any way else to do this without modifying the internal table data?

    Hi Alban,
    In your scenario, there are two records for DealID 1, and you want to sum it only once right? What would be expected sum if DealID is not 100 in both cases? What if you have 200 and 300 LoanAmount for DealID 1? Do you want an average in
    that case, first, last, minimal, maximal value or ...? If you want an average, then you can make 2 regular measures in your cube, one to do sum, the other to do count. Divide them and you'll have your average.
    In MDX you would sum AVG LoanAmount over distinct accounts like this:
    Sum( [Fact Table].[DealID ].[DealID ].MEMBERS,
         [Measures].[LoanAmount ] / [Measures].[Count of fact items]
    Regards,
    Charlie Liao
    TechNet Community Support

  • SUM Calculations

    Hi.
    I am using OracleBI Discoverer 10g (10.1.2.00.00) and am having an issue were I can't SUM a column. When try to sum the column I receive "Sum: " with no value. The things I have tried are: Changing the item to a detail, or Sum.
    Creating a Calculation using the Item.
    The data in the column are defined as a Number.
    Anybody have any ideas on what I can do to fix this.
    Thanks
    Anami

    If you refer to Discoverer documentation somewhere it is explained how it does the aggregations. For the totals, if Discoverer determines that the totals are invalid it will not display the result. consider a simple e.g
    Master Master_num Detail Detail_num
    m1 10 d1 1
    m1 10 d2 2
    m2 11 d4 8
    m2 11 d5 9
    Now if you ask Disco to total on Detail_num it will happily do it for you as there is "no duplication" of rows.
    If you ask Disco to total on Master_num, it will tell "sorry can't do that", why? because you have defined the joins in the EUL identifying the master-detail relationship. Using this join criteria it determines which columns can be aggregated.
    solution 1: Do a Cell sum on master_num, but if you just do cell sum it will show you (10 + 10 + 11 + 11) and if you pick distinct Cell sum then it will be (10+11)
    So depending on what you want pick the right choice.
    solution 2: change the join to one-to-one instead of master detail.
    solution 3 : usually all the totals should come from the detail folder if master and child elements exists together in the same report. avoid master totals.
    regards
    http://www.infocaptor.com
    Desktop BI tool

  • Can I use a Sum Calculation accross dynamically added rows?

    Well I have a working script that can add/delete extra rows to a table.
    And I have a working script that can calculate the sum of the columns.
    But when I put them together, the add row function stops working.
    Is there a way to reconcile the two?
    See attached example. It's actually not a real table, but subforms mimicking one.

    You keep making the same mistake. You cannot just copy the code from one form to another. Each form has a different structure and the code is showing the path to the object. Have a look at the HIerarchy view and see how to get to the object that you want from the root node. I have updated your sample to show this.
    Paul

  • Sum calculated rows and columns

    I have written a SQL report to count the number of offenses by levels of disciplinary actions.  Now I want to total
    the counts for the rows and columns.  How do I do this? Below is my code.  It produces column headings with counts.  Ie.
    Offense Description   Level I  Level II  Susps Terms
    2 Minor Violations      0         1       
    0    0  
    SELECT
    UPPER(DESCRIPTION) as OFFENSE,
    SUM(CASE
    WHEN OUTCOME = 'LEVEL I'
    THEN 1
    ELSE 0
    END) as LEVELI,
    SUM(CASE
    WHEN OUTCOME = 'LEVEL II'
    THEN 1
    ELSE 0
    END) as LEVELII,
    SUM(CASE
    WHEN OUTCOME = 'SUSPEND'
    THEN 1
    ELSE 0
    END) as SUSPEND,
    SUM(CASE
    WHEN OUTCOME = 'TERM'
    THEN 1
    ELSE 0
    END) as TERM
    FROM
    PAGRDI
    Where
    R_DATE >= '2014-01-01' and R_DATE <= '2014-01-31'
    Group by
    DESCRIPTION
    Order by
    OFFENSE

    Hi Wildcatgirl,
    According to your description, you have used T-SQL to get the counts for different OUTCOME. Now you want to get the total for each OFFENSE and OUTCOME. Right?
    In this scenario, since you have already get those counts with T-SQL query, so in your dataset it will have data fields below: OFFENSE, LevelI, LevelII, SUSPEND, TERM. We just need to drag these data fields into a table, add a column at the end of the table
    and use expression to sum the counts for different OUTCOME. Then we can add a total for the detail row. We have tested this scenario in our local environment. Here are screenshots for your reference:
    Reference:
    Tables (Report Builder and SSRS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Sum calculation inconsistent

    Hie Guys,
    I have a "Hours" column in my Webi Report with a Sum at the bottom. Now, if I leave the column values in decimals, then I get accurate values for Sum. However, if I format the column as Integer - FormatNumber([Hours];"#,##"), then the sum values are not accurate. For e.g.
    Decimal:
                  21
                 201
    Sum = 222
    Integer:
                 20.50
                200.50
    Sum = 221
    I want the values to be displayed in  Integers with accurate sum. I am using BO 4.1. Is there a way around this issue? Thanks.

    Hi Jeewan,
    First apply sum function on column,
    now change the format of column,
    now you can see output in require format with accurate sum values,
    Or else you can use round function to get accurate values.
    Regards,
    Samatha B

Maybe you are looking for