Doubt in calculating a ratio in a query

Good afternoon forum,
I have a question on how to calculate a ratio in a query.
I have 2 ratios: Actual Cost and Cost Periodificado. And from these two I have to calculate other ratios (WIP).
So the logic would be the following:
A) If the actual cost is greater than the cost periodificado, the difference in these two ratios correspond to the ratio WIP (WORK IN PROGRESS).
B) If the actual cost is <periodificado the cost, the difference in these two ratios correspond to the ratio WIP (PROVISION OF SPENDING)
To reveal a ratio or the other depending on which of two conditions is met.
If the condition is fulfilled, will be displayed in the query ratio WORK IN PROGRESS, and if the condition B is displayed on the query ratio
PROVISION OF SPENDING.
I do not know if I have explained well. Any suggestions?
Thank you.

The logic presented by Rakesh seems to be appropriate .
u need to follow and utilise the Boolean operators...
go to query designer
lets say the ratio u need to display is in columns
now right clik and say new formulae
from there select the Formulae operator as Boolean operators
use follwong formulae
WORK IN PROGRESS =  (actual cost > cost periodificado) * (actual cost - cost periodificado)
PROVISION IN SPENDING =  (actual cost < cost periodificado) * ( cost periodificado - actual cost)
Hit okey
go to actual costs properties
put the display option as HIDE
repeat the same for Cost periodificado
go to query properties
use the option SUPRESS ZERO VALUES FOR rows and columns....
this way u will only display the required result

Similar Messages

  • Help in calculating a ratio

    Good afternoon forum,
    I have a problem when calculating a ratio.
    It turns out that I have the following data:
    Center  Material  Stock
    C1            x1          5
    C1            x2          2
    C2            x1          7
    C2            x2          6
    And make needed in the following calculation.
    Sum of all ratios of stock  Nº Centers) ...
    In my case would be 26  2 = 13
    Someone I could lend a hand ...

    The logic presented by Rakesh seems to be appropriate .
    u need to follow and utilise the Boolean operators...
    go to query designer
    lets say the ratio u need to display is in columns
    now right clik and say new formulae
    from there select the Formulae operator as Boolean operators
    use follwong formulae
    WORK IN PROGRESS =  (actual cost > cost periodificado) * (actual cost - cost periodificado)
    PROVISION IN SPENDING =  (actual cost < cost periodificado) * ( cost periodificado - actual cost)
    Hit okey
    go to actual costs properties
    put the display option as HIDE
    repeat the same for Cost periodificado
    go to query properties
    use the option SUPRESS ZERO VALUES FOR rows and columns....
    this way u will only display the required result

  • How to use a calculated column in the same query

    Hi All,
    I need some help with using a calculated column in the same query.
    For eq
    I am joining a couple of tables and some of the select columns are calculated based on the columns of the tables and i want a new column in the same query to use this calculated feild in some other calcualtion.
    something like this...
    select (12+3) as Sum1, (12-3) as Sum2, (Sum1 + Sum2 ) as Sum3
    from dual
    or
    select (12+3) as "Sum1", (12-3) as "Sum2", CASE WHEN ( "Sum1" / "Sum2" * 100 > 0 ) THEN 'Yes' ELSE 'No' END
    from dual
    Thanks

    user548171 wrote:
    select (12+3) as Sum1, (12-3) as Sum2, (Sum1 + Sum2 ) as Sum3
    from dual
    or
    select (12+3) as "Sum1", (12-3) as "Sum2", CASE WHEN ( "Sum1" / "Sum2" * 100 > 0 ) THEN 'Yes' ELSE 'No' END
    from dual
    ThanksWhat about just repeating the column values:
    select (12+3) as "Sum1", (12-3) as "Sum2", CASE WHEN ( (12+3) / (12-3)  * 100  > 0 )  THEN 'Yes' ELSE 'No'  END FROM DUAL

  • Doubt on Rows and Coloums in BEx Query Designer.

    Hello, Experts.
    I have a Doubt in BEx Query Designer.
    In the Rows I have a Fiscal year Period,  if the user enters the Fiscal year period for e.g. : 001/2006  .  
    in the columns i have  forecast for the Fiscal year period which user entered ( 001/2006 ),   and we have another column pervious ( Prior )fiscal year period ( 001/2005 ). 
    My Questions is ,  as we are Restricting with 001/2006 will the query retrieve the values of 2005 or not?
    Thanks in Advance .
    Sharp

    yes i am  Doing Offest.
    I moved this Fiscal year Period to Free char,   and i Restricted with Pervious Fical Year period and Fical year period .  it worked.  but
    when i kept this in Rows and deleted Previous Fiscal Year period .  it is displaying blanks.   in prior years forecast.
    is it because i am Ristricting it to only fical year period  which user entered
             Colums-->  Forcast ( User Entered year )          Prior year
    Rows
    Fiscal year period
      Fiscal year period( user enterd )
    Thanks

  • 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

  • Taking display value for calculations using structures in Bex query

    Hi
    I am using Bex analyzer to do a simple report with two key figures ‘Sales’ and ‘Plans’ from cube and two more calculated key figures ‘Abs Deviation’ and ‘% error’. The report displays at category and product levels. Category is higher and one category contains multiple products.
    The simple formulas for the two calculated KF are,
    1. Abs Deviation = Abs (Sales – Plans).
    Abs Deviation is set with the property Calculate result as ‘summation’ to add up Abs deviations at product level to show at Category level.
    2. % Error = Abs Deviation / Plan.
    The issue is with the % Error value at category level. At product level, all the values are showing correctly.
    To illustrate the issue with a simple test case,
    CategryProductSale-PlanAbs Dev----%Error
    C1--P1--100-60---40--
    67%
    C1--P2---50120---70--
    58%
    C1 Total--150180---110--
    17%
    Observe that in the output the calculation for ‘%Error’ at product level is correct all the way. But the summary
    calculation for ‘Error%’ i.e. C1 total which is showing as 17% is wrong. The correct value as per the formula should be 110/180 = 61%.
    SAP, through OSS replied that it is not a bug but the default behavior of OLAP calculation. OLAP processor first calculates the formula for % Error and then shows the display value at C1 total for Abs Dev. Meaning, ‘% Error’ is calculated first and next the summation for Abs dev is displayed. Abs dev 110 at C1 level is only a display value but not the value taken for % Error at C1 level. Instead OLAP calculates the Abs Dev at C1 level by Total sale – Total plan = 180 – 150 = 30 and the % Error calculation takes this 30 value in the formula and gives % Error = 30/180 * 100 = 17% at C1 level. But 17% doesn't make any sense to the user. Further, to display value of 61% at % Error at C1, it is being advised that by defining two structures, I can force the calculation to take display value of 110 in the % Error calculation at C1 level by using the cell editor.
    Has any body tried to achieve similar result as above by defining two structures and cell editor in the query? If so, can you please throw some pointers of how to define two structures in a query and how to force the % Error at category level to take the display value of 110 in the calculation? I have gone through the documentaion on structures and cell editor but the approach is not at all clear.
    Thanks in advance for your suggestions.
    Prasad
    Unilever Asia IT department

    Hi,
    Have u read aabout the Formula Collision.
    Take a look on this link .
    http://help.sap.com/saphelp_bw32/helpdata/en/d2/02223c5f00612be10000000a11402f/frameset.htm
    Read the Formula Collision, and let us know , whether your pb is solved by changing the Formula Collision of % error formula.
    With rgds,
    Anil Kumar Sharma .P
    Kindly assign points , If it really helps you.

  • Representation 2 ratios in a query

    Good Morning Gurus,
    I have the following in a query. I have these 2 ratios defined in the lines in the query and broken down by cost center, and I would like to be represented in the report as follows.
    PREVENTA                                        Center cost
       Internal Cost Ratio
       External Cost Ratio
    WARRANTY
       Internal Cost Ratio
       External Cost Ratio
    As you see I have ratios represented in the query in lines and the characteristic (cost center) in columns. How can I make the 2 ratios were separated in preventa and Warranty, and also show these texts 2.
    Thanks. Greetings,

    Hi
    Take any other key figure & rename it as Preventa. In properties of this field you will get 2 option - calculate single value as & calculate result as, there you select 'Supress Result'. By doing this you will get blank row with heading as 'Preventa'.
    Else you can use 'New selection' also

  • Hide or show ratios in a query depend of the entry variable

    HI gurus,
    I wish hide or show rates depending if the user choose a entry variable. For example for 2008 dates take three ratios and for 2009 others.
    Thanks

    OK. WAD problem !
    Basically you need to use some HTML expertise to resolve this issue.
    Creat a new template with Radio button or a dropdown button which will contain the available values what user can select.
    something like as follows:
    o 2008
    o 2009
    Now this can be done using java script.
    You will have two different templates. One for 2008 query and second for 2009 query. Run them and get the URL of the reports.
    Then in the HTML on the "onSelect" event, put the URL.
    So if user selects the 2008, on the next page, you will see 2008 query and if they select 2009, then you will see 2009 query.
    - Danny
    Edited by: Danny Matt on Jul 10, 2009 3:08 PM

  • Color coded calculated list column in content query web part

    I have a calculated column in a list for displayig color coded values using the link
    http://blog.splibrarian.com/2012/06/06/using-calculated-columns-to-add-color-coding-to-your-sharepoint-lists/
    Now for rollup i am using the lists to display them in a content query web part so i have updated the .webpart file and imported and added, made changes in the item style and uploaded ad finally inserted the web part in the page.
    But while diplaying hte custom column, it is being eing displayed as
    string;#<DIV style='font-weight:bold; font-size:24px; color:green;'>•</DIV>
    As you can notice it has appended string;# before the text. How do i avoid this? Thanks

    <xsl:value-of-select="@RAG" disable-output-escaping=“yes”
    />

  • Calculation of Ratios

    We have a db with 6 dimensions:Accounts (dense)Time (12 months aggregated into 4 quarters - set with DTS for YTD and QTD) - Dynamic calc on QtrScenario (Actual 03, Actual 02, Plan 1 03, Plan 2 03 etc)Cost CentreBusinessAnalysis codeOur customer has devised some ratios that can Fall over into previous years - example :Average Income - MTD = (last month AI + this month AI) / 2QTD = (last month of previous quarter + current months of quarter) / (1 + months of current quarter) Note: this means if it is February then calc should be (December + January + February) / (1 + 2). If it was for April then it would be (March + April) / (1 + 1).YTD = (last month of previous year + current months of this year) / ( 1 + current months of this year) Note: this would be as per February example shown for QTD above.The issue is that this would mean that we would have to either calculate all these as fixed results by a long calculation string (bearing in mind that you have to use 2 different scenarios), or by some clever outline set up.Does this mean that we would have to introduce a new dimension for years, and amend the scenario so that it referred to the process e.g. Actual, Plan 1, Plan 2 ?A further complication is that Plan 1 in 03 covers all 12 months for 2003 and also 12 months for 2004. Plan 2 covers last 6 months of current year, plus 12 months for 2004, 12 months for 2005 and 12 months for 2006.Also, how can we get it to work so that the user can specify which month they are looking at and still return the correct answers.Any information / suggestions would be fantastic, as they sprung this upon us yesterday, and we have 3 days to get it in and working !!

    Are you using Essbase 6.5.1 or above? This version introduced some new calc fucntions that help calcualting ranges across two dimensions - @XRANGE and @MOVSUMX

  • Retrieving Detailed Calculation in a group by query

    I am writing a query that has a calculation based on an ID column or every detailed record in the table, but the output/report needs to be grouped by another column. The calculation is days_open/count(*). The days_open column is a field in the table.
    The output should be
    Case Type Avg_days_open
    A 20
    B 31
    C 34
    D 55
    The days open column in the table is structured like this:
    ID Days_Open
    1 34
    2 10
    3 23
    My query below is retrieving dupes per case type.
    select a. case_type_cd,
    days_between_sum/count(*) avg_days_pending
    from tab a,(select distinct case_type_cd, Days_Between days_between_sum from tab ) d
    WHERE FILED_DT between to_date(:BEGIN_Dt,'mm/dd/yyyy') and to_date(:END_Dt,'mm/dd/yyyy')
    and reporting_nr like :RID and federal_state = :FEDERAL_STATE
    and description is null
    and d.case_type_cd(+) = a.case_type_cd
    GROUP BY a.case_type_cd, days_between_sum

    Case Type case_nbr determination_dt Filed_dt
    A 123 10/02/2005 09/09/2005
    B 222 09/01/2004 07/01/2004
    C 094 01/01/2006 11/23/2005

  • Help assigning a   calculated arbitrary  ID to a query result set

    Given the sample query result..
    (sorry about the formatting of the output)
    GROUPID LAST_NAME FIRST_NAME INITIALS EMAIL PHONE count(PHONE)
    GP2001 Troy Diana s [email protected] 123-456-7890 2
    GP2001 Troy Diana s [email protected] 123-456-7890 2
    GP2006 Thomas Carl p [email protected] 789-100-1112 1
    GP2007 Riker William T [email protected] 866-908-6654 1
    GP3001 Laforge Jody m jlaforge@enterprisenet 456-789-9000 3
    GP3001 Laforge Jody m [email protected] 456-789-9000 3
    GP3001 Laforge Jody m [email protected] 456-789-9000 3
    GROUP_ID is a calculated field from a select statement.
    Individuals with one phone number (ph_cnt = 1)
    is assigned an arbitrary unique GROUP_ID.
    Individuals, appearing more than once, with more than one phone (ph_cnt > 1)
    are giving the same GROUP_ID.
    I was thinking of using a case statement in this case...but got stuck on generating the GROUP_ID based
    on the phone count.
    select case
    when ph_cnt = 1 then select 'GP'||to_char(sysdate,'hhmisssss') from dual)
    when ph_cnt > 2 then <assign a unique group_id to each set of duplicates/triplicate...etc>
    end GROUP_ID,
    last_name,
    first_name,
    initials,
    email,
    phone
    (select last_name,
    first_name,
    initials,
    email,
    phone,
    count(phone) ph_cnt
    from my tab
    group by
    last_name,first_name,initials,email,phone)
    Edited by: ch**** on Apr 25, 2011 7:20 AM

    Try this,
    SELECT 'GP' || 1000 + DENSE_RANK () OVER (ORDER BY phone ASC) groupid,
           last_name,
           first_name,
           initials,
           email,
           phone,
           COUNT (1) OVER (PARTITION BY phone) ph_cnt
      FROM my tab;G.

  • Calculating Vacation Days using a query

    Hi everyone. I have an issue with the following query provided by Pollywog. He did a great job on it however there is a bit of a problem in the way it operates. What it does is calculate the number of days for this year excluding saturday and sunday. It also has a cutoff date, July 1st. This is where the problem lies.
    Currently if the user chooses a vacation day that includes the cut off date. So from june 30th to july 5th it doesn't bundles it together and calculates it into the next year total. So if you have a vacation from June 15th to July 2nd it all goes into your next year's vacation days.
    What I want is to have this year's vacation days be calculated into this year and next year to be calculated into next year. So if you have the June 15th to July 2nd vacation it would add 11 days to This year's total and 2 days to next year's total.
    WITH t AS (  SELECT id,
                        MAX (strt) strt,
                        MAX (finish) finish,
                        SUM (dys) days_off
                   FROM (SELECT id,
                                strt,
                                finish,
                                CASE
                                   WHEN TO_CHAR (dy, 'day') LIKE 'saturday%' THEN 0
                                   WHEN TO_CHAR (dy, 'day') LIKE 'sunday%' THEN 0
                                   ELSE 1
                                END
                                   dys
                           FROM vacations
                         MODEL
                            PARTITION BY (ID id)
                            DIMENSION BY (0 d)
                            MEASURES (POCETAK strt, KRAJ finish, POCETAK dy)
                            RULES
                               (dy [FOR d FROM 1 TO finish[0] - strt[0] INCREMENT 1] =
                                     (NVL (dy[CV () - 1], dy[CV ()]) + 1)))
               GROUP BY id
               ORDER BY id)
    SELECT t.id,
           t.strt,
           t.finish,
           t.days_off,
           vacations.korisnik,
           SUM (
              CASE
                 WHEN finish < TO_DATE ('01/07/2011', 'dd/mm/yyyy') THEN days_off
                 ELSE 0
              END)
           OVER (PARTITION BY vacations.korisnik ORDER BY t.id)
              this_years_running_total,
           SUM (
              CASE
                 WHEN finish < TO_DATE ('01/07/2011', 'dd/mm/yyyy') THEN days_off
                 ELSE 0
              END)
           OVER (PARTITION BY vacations.korisnik)
              this_years_grand_total,
           SUM (
              CASE
                 WHEN finish >= TO_DATE ('01/07/2011', 'dd/mm/yyyy')
                 THEN
                    days_off
                 ELSE
                    0
              END)
           OVER (PARTITION BY vacations.korisnik ORDER BY t.id)
              next_years_running_total,
           SUM (
              CASE
                 WHEN finish >= TO_DATE ('01/07/2011', 'dd/mm/yyyy')
                 THEN
                    days_off
                 ELSE
                    0
              END)
           OVER (PARTITION BY vacations.korisnik)
              next_years_grand_total
      FROM t, vacations
    WHERE t.id = vacations.idLooking forward to any ideas you can offer

    hi,
    You need to write a code to get the key figure and characterstics value.
    First step is to defined the structure of all the field that you want to read.
    This table I_AXIS_DATA will contain the characterstics.
    This table I_CELL_DATA will contain the keyfigure.
    Please find the code.
                READ TABLE I_AXIS_DATA INTO WA_AXIS_DATA WITH KEY AXIS = '001' .
                IF SY-SUBRC = 0.
                  LOOP AT WA_AXIS_DATA-SET INTO WA_SET.
                        INDEX = INDEX + 1.
                        IF WA_SET-CHANM = 'infoobject name'.
                          WA_ROW_COL-fields = WA_SET-CHAVL_EXT .
                        ENDIF.
                        IF WA_SET-CHANM = 'infoobject name'.
                          WA_ROW_COL-field2 = WA_SET-CHAVL_EXT.
                        ENDIF.
                  ENDLOOP.
                ENDIF.
    ******* POPULATE COLUMNS AGAINST ROWS
                CLEAR WA_ROW_COL.
                V_COUNT = 1.
                INDEX = 1.
                LOOP AT IT_ROW_COL INTO WA_ROW_COL.
                  WHILE ( V_COUNT <= V_NUMOFKEYF ).
                        READ TABLE I_CELL_DATA INTO WA_CELL_DATA INDEX INDEX.
                        IF V_COUNT = 1.
                          WA_ROW_COL-keyfigure = WA_CELL_DATA-FORMATTED_VALUE.
                        ENDIF.
                        V_COUNT = V_COUNT + 1.
                        INDEX = INDEX + 1.
                        CLEAR WA_CELL_DATA.
                  ENDWHILE.
                  APPEND WA_ROW_COL TO IT_R_C_H.
                  V_COUNT = 1.
    Hope this is helpful.
    Thanks,
    Saveen Kumar

  • Doubt in calculated kf

    hi,
    when we deal with calculated key fig where does the value for those kfs get stored into.
    thanks

    Hi Ravi,
    The value of calculated key figures are generated at run time when the query is executed, therefore the values are not physically stored.
    Regards,
    Demetrius.

  • Calculating total time from a query

    Hi everyone,
    I have a simple database and one of the fields in this
    database is time spent on stuff, for example a bike ride lasted
    00:45:00, 01:33:03, 01:23:03 ETC
    what I am trying to do is calculate total time. so do a sum
    of that column.
    Simple enough.
    the column is a VarChar, I tried Time as well and well that
    did not go well.
    if I use mysql command line I get this:
    mysql> SELECT SUM(mv_time) FROM data WHERE user_id = 2;
    +--------------+
    | SUM(mv_time) |
    +--------------+
    | 8 |
    +--------------+
    1 row in set (0.00 sec)
    No idea how it came up with that one as 8 is incorrect
    so I got a bit fancier:
    mysql> SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(mv_time))) AS
    mv_time FROM data WHERE user_id = 2;
    +----------+
    | mv_time |
    +----------+
    | 26:14:58 |
    +----------+
    1 row in set (0.00 sec)
    Bingo that is correct.
    but if I use that same query within cfquery I get a nice java
    error telling that you can't have 26 hours in a single day.
    Any ideas how I can accomplish this should be simple task?
    Thank you.
    Luc

    Hi Cf_dev2,
    How would I go about making easy for my users to submit the
    seconds into the database?
    for example I would want them (them being me really :) ) to
    enter 01:35:00 (for one hour and 35 minutes) and then have CF or
    SQL convert that to seconds (instead of having myself figure that
    out manually I am no good at math)
    Jdeline, I don't understand what you mean by not storing it
    as comma delimited, as far as I know its not comma delimited, its
    stored in a table called data along with a primary key id, userid,
    date, etc
    Thanks
    Luc

Maybe you are looking for

  • [SOLVED]error: attempt to read or write outside of partition

    Hello, I update my system at least once a week, sometimes I run pacman -Syu more than that. So this system is no more than about 7 days behind what is available today.  Last time I did this the kernel got updated and it updated itself again or at lea

  • Adobe Camera Raw 8.4 RC "Update not applicable"

    I just tried to install Camera Raw 8.4 RC and got the message that the update is not applicable. I have PS CC and LR installed via CC. Adobe Twitter Support redirected me here. Has anyone an idea of what to do? Is there any log of the update process?

  • Too much security in Mountain Lion

    I only switched to Mountain Lion last week. It seems that every time I do anything I get a pop up asking for my password. I am the only person who can access my Mac, so is there a way I can switch all this security off, or some of it. Examples: I sta

  • Bdc for Vlo2 in session method

    Hi Guru's Please help me out. Will reward with the points for the helpfull answers. I need to create a session method for the 'VL02' Transaction. I need to Record as VL02-----> Overview-- > Picking. The only field which i have to enter in the First s

  • Error 2755?

    How's that for a unique problem? First of all, I never could get iTunes 6 to even start installing so this is a step forward, haha, as I actually managed to get the PROGRAM to crash rather than the installation... these are the problems: - At least t