How to calculate a column bases on the result of another column?

Hello folks, i need some help with this senario.
I don't know to explain this in a simple way, but i'll give it a go.
I display a report in ApplicationExpress like this
Each row displays a product where the user are going to make a forecast for 18 months ahead.
[productname] [Stock] [sales] [PMonth] [NewstockMonth] [salesmonth1]      [ProductionMonth1]     [NewstockMonth1] ....
[product1]______[10]____[5]____[0]_________[5]__________[10]_________[10]______________[5]
[product2]______[2 ]____[0]____[0]_________[2]__________[5]__________[10]______________[ 7]
[product3]______[30]____[20]___[0]_________[10]_________[5]_________[10]______________[15]
Stock and sales are results of a function i have in my select.
productionmonth is a text field where the user can edit the production and is saved in the table.
So when the user has entered some inputs in the textboxes, and pressed the submit buttom, the newstockmonth columns
should be calculated from the result i get from the previous month.
newstockmonth = (stock-sales)+productionMonth
newstockmonth1 =(newstockmonth-salesmonth1)+productionmonth1
At this point my submit process has update in a for loop for each row. But i don't quite know how i can calculate every newstockmonth columns.

Hi Klaus,
your condition only works if the Shop is in the query. If I understood it correctly you have one query with
Country   Shop   Total Sales
and one with
Country   Number of Shops   Total Sales
and you don't want to restrict the second Total Sales but the Total Sales from the first query.
Best regards
   Dirk

Similar Messages

  • Update one column while getting the value in another column

    Is it possible to in one single SQL statement update two columns in a table while at the same time obtaining the value of another column, on the same row, in the same table, and independently (that is, the update of the columns has nothing to do with the data that I want from another column)*?* Of course, I can do this in two operations, one being a "select" and the other one being an "update", but since I am in the same table and even on the same row, is it really necessary to make TWO database calls? That's why I want to combine the the two SQL-statements, for reasons of presumed effiency.

    jsun wrote:
    Is it possible to in one single SQL statement update two columns in a table while at the same time obtaining the value of another column, on the same row, in the same table, and independently (that is, the update of the columns has nothing to do with the data that I want from another column)*?* Of course, I can do this in two operations, one being a "select" and the other one being an "update", but since I am in the same table and even on the same row, is it really necessary to make TWO database calls? That's why I want to combine the the two SQL-statements, for reasons of presumed effiency.Two statements != two database calls.
    At least not in terms of SQL.
    JDBC requires a 'statement' but in SQL (depending on the data source) that can include multiple statements. An obvious example of this is a stored proc but there are other ways as well.

  • How to calc sum of one column, based on the condition of another column?

    I would like to create a formula that adds up the total cost from column F for each specified service in column D. For example, the result for PM (project management) would be $495. Any ideas?

    I think you could use this formula, using your cell references:
    =SUMIF(D4:D21,"=CM",F4:F21)
    Then, change the "=CM' to "=PM", etc. for each service.
    Like JaxJason, I can't test this in Numbers right now, but it works in Excel, and the functions are identical.
    SUMIF(test-range, "condition", [sum-range]):
    * test-range: A reference to the range of cells containing values to test. Must be the same dimensions as sum-range.
    * "condition": Any comparison statement that results in a logical TRUE or FALSE value.
    * sum-range: Optional; a reference to the range of cells containing the numbers to be added. Must have the same dimensions as test-range. If omitted, test-range is used.
    I hope this helps.
    - Michael
    Message was edited by: Apple fan Michael

  • Making a new column out of the values from another column

    I am trying to query the transaction table and the promotion table to get the following output..
          select t.no, t.date,p.groupid,p.promocode,sum(t.salesamt)
          from trans t, promo p
          where t.id=p.tid
          group by t.no,p.groupid,p.promocode,t.date
          order by t.date
    no
    date
    groupid
    promocode
    promodesc
    sum(t.salesamt)
    m12
    01-jun-2012
    09
    p12
    Promotion1
    7890.00
    m12
    01-jun-2012
    09
    p13
    Promotion2
    345.56
    m12
    01-jun-2012
    09
    p14
    Promotion3
    2345.90
    m12
    01-jun-2012
    09
    p12
    Promotion1
    345.12
    m12
    01-jun-2012
    09
    p13
    Promotion2
    23678.00
    m12
    01-jun-2012
    09
    p14
    Promotion3
    3456.78
    I want to remove the promodesc and the sum(t.salesamt) and add Promotion1,Promotion2,Promotion3 as three new columns and their respective sum(t.salesamt) as their data value.
    I am thinking about using three separate case statements to achieve this...
    sum( case when promocode='p12' then t.salesamt end) Promotion 1
    Please let me know if there is any other optimal way to achieve this.
    Thank you!

    Hi,
    What you want is called a Pivot.  Using CASE expressions (like you described) is one common way to do pivots.  If you're using Oracle 11.1 (or higher) then you'd probably want to use the SELECT ... PIVOT feature instead.  See the SQL Language manual
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#sthref6809
    and the forum FAQ
    https://forums.oracle.com/message/9362005
    for details and examples.
    If you get stuck, post your best attempt, along with CREATE TABLE and INSERT statements for a little sample data, and the results you want from that data (if different from what you've already posted).
    Always say which version of Oracle you're using (for example, 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to make a report based on the result of another report?

    Hi, All,
    I am a new guy in BW development
    I  made the report1, to show the "Total Sales in each country and each shop "
    (the fact table is "Order")
    now I want to make report2 "in each countries, the number of the shops, whose Total Sales >100000"
    Can I make the report2 based on the result of report1 (use the same fact table)
    thanks a lot
    QY

    Hi Klaus,
    your condition only works if the Shop is in the query. If I understood it correctly you have one query with
    Country   Shop   Total Sales
    and one with
    Country   Number of Shops   Total Sales
    and you don't want to restrict the second Total Sales but the Total Sales from the first query.
    Best regards
       Dirk

  • Conditionally Formatting One Column Based On The Value of Another Column

    I have the following requirement:
    I have 2 columns in a report showing Actual Sales & Budget Sales each year. I am using a bar chart to show the different values for these 2 columns.
    I need to conditionally format the column "Actual Sales" so that if it is less than the "Budget Sales" it will appear in red, and green if "Actual Sales" is greater than "Budget Sales." So in a nutshell,
    CASE WHEN "Actual Sales" < "Budget Sales" THEN
    RED
    ELSE
    GREEN
    END
    Thoughts anyone?

    CASE WHEN (COL1 - COL2) < 0 then Red else Green end
    regards
    John
    http://obiee101.blogspot.com

  • Set the css style of text in a column according to the value of another col

    I'd like to set the css style of text in a column according to the value of another column. Each field may end up with a different style of text as a result, for instance.
    Any ideas? I looked thru the forums but couldn't find anything.
    Thanks,
    Linda

    Does the class=”t7Header” make it into the rendered HTML?
    ---The text "class="tHeader" does not show but the other text is rendered using the style t7Header as defined in the stylesheet! Exactly what I wanted.
    You might want to use a div or a span instead of a p.
    ---Yes -
    What's very cool is we can create a display column that is dynamically filled with the html and style wrappers based on a lookup to see what style should be applied according to the actual data value. This is critical as our tables are all dynamic so I can't depend on using the additional APEX methods to control the display of a column (as the # of columns in the view vary from instance to instance) and I did not want the display specs to muddy up my SQL queries.
    I wonder why this is not well documented. It is so easy!
    Thanks again for your help.
    Linda

  • How to change font size, maximum column size in the result screen ?

    hi All
    That's great when using SQL Dev.
    But I also have a trouble that how to change font size, maximum column size in the result screen ?
    My users think that font in result screen is shown very small, and whenever the data in each colum is long then it's not shown full data in column, they must double click for extend the size. Have the option to default the max size for showing full data in each column ? I try but still not to do that .
    Appreciate for anyone to help us.
    Thanks all.
    Sigmasvn

    You can't change the font for the results screen yet, however you will be able to select an auto-fit option for selected columns, so if some columns have slitghtly wider text you'll be able to set the column widths to handle these wider columns.
    Also, there s the option of switching the layout of a record in the grid.
    Sue

  • Not able to see the result in particular column of BPC report

    Dear All,
    I have problem in one of the BPC report where I am not able to see the result into one column but rest of the users are able to see the result for same column in same report without any issues.
    Generally, I used this report frequently but having such problem from last few days. Excel has created any logs which I need to clear? Please advice.
    Request your help to resolve such problem please.
    If you need any information, please let me know.
    Thank You
    Kind Regards
    Anukul

    Hello Anukul,
    In the report what type of data you are trying to check in that column. can you please brief about report.
    And also please check the excel cell format (right click and check it is a numeric or character), which may help to resolve this issue.
    Regards,
    Rajesh.K

  • How do I change a character in the document to another character in one command?

    How do I change a character in the document to another character in one command?

    You mean everywhere? Use Find/Change

  • How come every time i'm on the phone and another call enters I answer it but it doesnt tell me anywhere who is who on each line so i can go back and forth?? it only says multiple calls and i cant hang up the other line

    how come every time i'm on the phone and another call enters I answer it but it doesnt tell me anywhere who is who on each line so i can go back and forth?? it only says multiple calls and i cant hang up the other line.

    My carrier is Sprint. But I actually have checked with others and theirs work fine.

  • TS1389 how to authorize computer in itunes for the purchased from another account

    how to authorize computer in itunes for the purchased from another account ??

    Use that account's Apple ID and password; the procedure is otherwise the same as authorizing it for the first account. If the iTunes library contains protected content from more than five iTunes Store accounts, you may not be able to fully sync it.
    (92807)

  • My e-mail has quit updating.  Anybody know why or how to get it started back?  The result is that I dont get my e-mails on the phone.

    My e-mail has quit updating. Anybody know why or how to get it started back?  The result is that I can not get e-mails on my phone.

    Thank you for the info re. the main menu. Your answer I used worked; however, the menu bar all the way across is solid black. The only way I can find out the names on the menu is to point the cursor from left to right over the black bar to find "file" "edit" tools", etc. What do I need to do to get these menu titles to be seen?
    As regarding the GMail --the menu bar used to have an envelope symbol which was white and outlined in red. That disappeared. I googled "mail.google.com" to try to get back my email. This didn't work. I then tried to get a different email address and password--after 8-19 attempts, this never worked. My other email (sbcglobal.net) has never returned. So I don't know where that went or how to get it back

  • How long does it take to get the result of hands-on-course test?

    Hi:
    I passed 1Z0-043 and submitted hands-on-course.
    How long does it take to get the result? And how long does it take to get the certificate?
    Another question:
    Is there any place you can search for OCPs?, just to check those people who have fake certificates.
    Saad,

    S.Nayef wrote:
    Hi:
    I passed 1Z0-043 and submitted hands-on-course.Congratulations!
    How long does it take to get the result? And how long does it take to get the certificate?Submitting hands-on-course should take 2-3 weeks. After that, you'll wait approximately 1 month to get certificatre
    Another question:
    Is there any place you can search for OCPs?, just to check those people who have fake certificates.NO there's not
    >
    Saad,

  • OBIEE Report - filter based on the result from another analysis

    Hi,
    I am using OBIEE 11g,
    I am trying to use a filter which is based on the result from another analysis. I have an analysis A which is as table 1, and I want to filter the respective columns of analysis B (Table B) based on analysis A to remove the duplicates for march 01, 02, and 07 , but it is not working properly. I took a max of start and end time when I created analysis A. Please let me know if I did anything wrong. thanks.
    Table 1
    Employee Number
    Date
    IN
    Out
    Start Time
    End Time
    xxxxxxx
    2015-02-26
    9:00
    13:00
    00:00:00
    00:00:00
    2015-02-27
    12:00
    18:00
    00:00:00
    00:00:00
    2015-02-28
    8:00
    14:00
    00:00:00
    00:00:00
    2015-03-01
    14:00
    20:00
    14:00:00
    20:00:00
    2015-03-02
    16:00
    20:00
    16:00:00
    20:00:00
    2015-03-07
    14:06
    20:02
    14:00:00
    20:00:00
    2015-03-11
    16:00
    20:00
    16:00:00
    20:00:00
    2015-03-14
    8:00
    14:00
    00:00:00
    00:00:00
    2015-03-25
    14:00
    20:00
    16:00:00
    20:00:00
    Table 2
    Employee Number
    Date
    IN
    Out
    Start Time
    End Time
    Hours
    xxxxxxx
    2015-02-26
    9:00
    13:00
    00:00:00
    00:00:00
    -3
    2015-02-27
    12:00
    18:00
    00:00:00
    00:00:00
    6
    2015-02-28
    8:00
    14:00
    00:00:00
    00:00:00
    6
    2015-03-01
    14:00
    20:00
    00:00:00
    00:00:00
    6
    14:00:00
    20:00:00
    6
    2015-03-02
    16:00
    20:00
    00:00:00
    00:00:00
    4
    16:00:00
    20:00:00
    4
    2015-03-07
    14:06
    20:02
    00:00:00
    00:00:00
    6
    14:00:00
    20:00:00
    6
    2015-03-11
    16:00
    20:00
    16:00:00
    20:00:00
    4
    2015-03-14
    8:00
    14:00
    00:00:00
    00:00:00
    6
    2015-03-25
    14:00
    20:00
    16:00:00
    20:00:00
    4

    Why avg here?
    What columns you want to show in the report?
    for a employee for given date if he have 2 rows then you may sum up hours right?
    Employee Number
    Date
    IN
    Out
    Start Time
    End Time
    Hours

Maybe you are looking for