How to put this condition in Query

Dear experts,
I have a scenario where in the calculation should be dynamic between key figures in query
For example i have a
Target Cost and Actualcost1, Actualcost2, Actualcost3
i need to findout the variance between the Target and Actual
but the catch is that i need to findout the variance with the latest actual cost
1. )  Target cost = 100
Actual cost1=10, Acutal cost2=0, actual cost3=0
then the formula should be Actual cost1-target cost
2. )But if
Target cost  =100
Actual cost1=10, Actual cost2=5, Actual cost3=0
then the formula should be Actual cost2- Target cost
3. Target cost =100
Actual cost1=10, Actual cost2 = 5, Actual cost3= 15
then the formula should be Actual Cost3-Target cost
How to achieve this
Thanks and regards
Neel

Hi Neel,
Do you have indicator saying that a particular actual cost is the latest? If you have any indicator thsi would make the job easy. Else you need to create new formulas to derive the logic.
Else you can proceed with the belwo logic.
1.target cost
2. Actual Costs 1 - Hide
3. Actual Costs 2 - Hide
4. Actual Costs 3 - Hide
5. New formula whcih evaluates the latest.
Write the condition
If Actual costs3 = 0 and actual cost2 = 0 then actual cost1.
else if actual cost2= 0 then actual cost1
else if actual cost1 NE 0 and actual cost2 NE 0 then Actual cost3.
Then hide the above new formula.
And in a new formula you can find the diff between the Target cost and the latest cost derived in teh above new formula.
If the conditions is too big in the above new formula, you can split across two three new formulas and derive the logic.
Just make some changes to the above logic if it is not 100%.
I believe this logic will work.

Similar Messages

  • How to put distinct in the query

    Hi all,
    How to put distinct in the query.I checked in RPD , Distinct supported is already available. I marked the distinct check box in advance option still then i'm not getting distinct in the query.
    any idea , please help...

    In the RPD i have join between base table and view .i'm selecting 2 columns one from base table and other from view . which gives cartesian product . to avoid that i want to put distinct . I'm not using any measure . I'm taking direct columns.
    I'm getting distinct keyword if i'm accessing the report directly . but when i'm accessing it from dashboard in the back end while preparing the query it's writing distinct but the actual query which is sending to db does not have distinct.
    ==================================================
    RqList distinct
    VW_SCNR_114000074_TA_DATA.Match Identifier as c1 GB,
    VW_SCNR_114000074_TA_DATA.Tot Trans Amt as c2 GB,
    VW_SCNR_114000074_TA_DATA.Tot Trans Ct as c3 GB,
    case when VW_SCNR_114000074_TA_DATA.Alert Quality Code = '1' then 'Productive' when VW_SCNR_114000074_TA_DATA.Alert Quality Code = '2' then 'Non Productive' else 'Indeterminate' end as c4 GB,
    VW_SCNR_114000074_TA_DATA.Batch Identifier as c5 GB
    DetailFilter: Alert TA Data.Run Id > 0 and Alert Scenarios.Scenario Name = 'ScnroName' and Alert TA Data.Batch Id > 0
    OrderBy: c4 desc
    =================================================
    -------------------- Sending query to database named KYC1.1DEV-179 (id: <<16315>>):
    select T353.BATCH_ID as c1,
    case when T353.QLTY_RTG_CD = '1' then 'Productive' when T353.QLTY_RTG_CD = '2' then 'Non Productive' else 'Indeterminate' end as c2,
    T353.TOT_TRXN_CT as c3,
    T353.TOT_TRXN_AM as c4,
    T353.BREAK_ID as c5,
    T117.SCNRO_NM as c6
    from
    KDD_SCNRO T117,
    KDD_TA_DATA T130,
    KDD_TSHLD_SET T171,
    VW_SCNR_114000074_TA_DATA T353
    where ( T117.SCNRO_ID = T130.SCNRO_ID and T117.SCNRO_ID = T171.SCNRO_ID and T130.SCNRO_ID = T171.SCNRO_ID and T130.SCNRO_ID = T353.SCNRO_ID and T130.TSHLD_SET_ID = T171.TSHLD_SET_ID and T171.SCNRO_ID = T353.SCNRO_ID and T171.TSHLD_SET_ID = T353.TSHLD_SET_ID and 0 < T130.BATCH_ID and 0 < T130.RUN_ID )

  • How to map this condition in XI

    Hi all,
    Please can any one tell how to proceed this condition in XI map :
    Please any one provide some solution, bcoz its hamppering my development.
    EITHER(
                                                       EXTRACT(
                                                                       Group_3:Group_1,
                                                                       EAN11 E2MARMM002 Field:E2MARMM002 Segment:Group_3:Group_1 != ""  &
                                                                       MEMBER(
                                                                                    MEINH E2MARMM002 Field:E2MARMM002 Segment:Group_3:Group_1,
                                                                                    MEINH_SAP Fileds:Target_Market                                                                               
                                                       FAIL(
                                                                " No Valid MEINH (UOM) found in given IDoc for Material Number = " +
                                                                  TRIMLEFT(MATNR E2MARAM005 Field:E2MARAM005 Segment:Group_1, "0") + "," +
                                                                 " Either correct MEINH (UOM) in the IDoc or configure MEINH for the material number in file " +
                             GETFILENAME( SAPMW_Lookup )
                                             Group_5,
                                             Group_1,
                                             SAPMW_Lookup,
                        Variant_Language_Lookup                  
    Message was edited by:
            vijaya laxmi
    Message was edited by:
            vijaya laxmi

    HI Ranga Rajan,
    Now, here i am pasting new condition which was used in mercator.
    But the same condtion i have to use in XI also, so please explain indetail  interms of XI.
    =IF(  MEINH E2MARMM002 Field:E2MARMM002 Segment:Group_3_MATMAS05_V1_UNI = "D97" &
            EAN11 E2MARMM002 Field:E2MARMM002 Segment:Group_3_MATMAS05_V1_UNI != "",
            IF(TRIMLEFT(TRIMRIGHT(#GLB#MATSW #GLB#XGT_E1MARA1000 Field:#GLB#XGT_E1MARA1000 Segment:Group_1_MATMAS05_V1_UNI)) != "",
          F_04_CreateUOMSW(
                                           LOOKUP(
                                                           UOMSW:UOMSW_File:SAPMW_Lookup,
                                       TRIMLEFT(TRIMRIGHT(#GLB#UOMSW #GLB#XGT_E1MARA1000 Field:#GLB#XGT_E1MARA1000 Segment:Group_1_MATMAS05_V1_UNI)) =
                                             TRIMLEFT(TRIMRIGHT(UOMSW_SAP Fileds:UOMSW:UOMSW_File:SAPMW_Lookup))

  • How to get this condition right ?

    Hi Friends,
    Please tell me , How to get this condition right.
    Current Date = Posting date (RBKP.BUDAT) + 7 (i.e. notifications are sent 7 days after the Posting date).
    I need to get the blocked invoices which are overdue for 7 days, and send these blocked invoices. How to do the declaration and get it right ...
    thanks in advance ...
    Edited by: Matt on Jan 28, 2009 2:38 PM - subject amended by moderator

    Hi, SK SIDDIQUI
    Have a look at following code will solve out your problem,
    TABLES: RBKP.
    data: it_rbkp like STANDARD TABLE OF rbkp WITH HEADER LINE,
          wa_it_rbkp like rbkp,
          p7date like sy-datum,
          p14date like sy-datum,
          p21date like sy-datum.
    p7date = sy-datum - 7.
    p14date = sy-datum - 14.
    p21date = sy-datum - 21.
    SELECT * from rbkp
      into CORRESPONDING FIELDS OF TABLE it_rbkp
      where budat <= p7date. " for 14 just Replace p7date with p14date and for 24 just Replace p7date with p24date
    Please Reply if any Problem,
    Kind Regards,
    Faisal

  • How to Perform this calculaction in Query

    Hi Experts
    How can i achieve this Calculaction at query Level.
    Data:
    Emp_ID--Wage_IDPayroll_Date--Amount
    1--03925.01.2008-5000
    1--03925.02.2008-5000
    1--03925.03.2008-5000
    1--03925.04.2008-6000
    1--03925.07.2008-6000
    The employee will have No of different Wage types in his pay run.
    But as per my requirment i want to calculacte Employee Salarly.
    Lets Consider Wage Type 039 which is Salarly
    The Cal i need to perform is
    Select the Wage Type 039 and then Select the Latest (25.07.2008) Payroll date and then select the amount assiociated with it for and the 12* amount give salarly
    In the above case aslarly should be 72,000

    Hi,
    Soluition can be the following:
    Put Pay_Roll_date also as a key-figure in your cube and add to columns.
    Add condition (top 1) on keyfigure,
    In Character Assignment tick ïndividual char. and Char combinations.
    Tick also Emp_id and Wage ID. do not tick Pay_Roll_date (the characteristics, not the keyfigure)
    Hide key-figure Pay_roll_date & Amount
    Make calculated keyfigure Salary = 12 * Amount.
    That should do it.
    Udo

  • How to put the form in Query mode

    Hello
    Please let me know how to put the form or block in Query mode , so that when i run the form it should be in Query mode . I have seen properties of SET_FORM_PROPERTY and SET_BLOCK_PROPERTY but cannot find one
    Thanks

    QUERY mode? Did you mean, that you can only QUERY without changing data.
    This is the QUERY-ONLY-mode, which can be started e.g. call_form
    this is the help for that topic:
    PROCEDURE CALL_FORM
    (formmodule_name VARCHAR2,
    display NUMBER,
    switch_menu NUMBER,
    query_mode NUMBER,
    data_mode NUMBER,
    paramlist_name VARCHAR2);
    query_mode     
    NO_QUERY_ONLY (The default.) Form Builder will run the indicated form in normal mode, allowing the end user to perform inserts, updates, and deletes from within the called form.
    QUERY_ONLY Form Builder will run the indicated form in query-only mode, allowing the end user to query, but not to insert, update, or delete records.

  • How to Use MAX condition using Query Report

    Hi SAP Abap Expert,
    Can we use the MAX condition in Query Report (SQ01/SQ02) ?
    I have created one sample query using table VBRP and VBRK then i need to use max condition to get the MAX record in VBELN.
    Please Help ???

    Hi Ashishsingh,
    According to your description, you want to know how to use MAX function in SQL Server Analysis Services MDX Query, right? In this case, please refer to the link below which describe the syntax and sample of MDX function.
    http://technet.microsoft.com/en-us/library/ms145601.aspx
    http://www.mdxpert.com/Functions/MDXFunction.aspx?f=64
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to Achieve this in SQL Query?

    How to Achieve this ?
    I have a table with numeric value populated like this
    create table random_numeral (numerals Number(10));
    insert into random_numeral values (1);
    insert into random_numeral values (2);
    insert into random_numeral values (3);
    insert into random_numeral values (4);
    insert into random_numeral values (5);
    insert into random_numeral values (6);
    insert into random_numeral values (56);
    insert into random_numeral values (85);
    insert into random_numeral values (24);
    insert into random_numeral values (11);
    insert into random_numeral values (120);
    insert into random_numeral values (114);
    Numerals
    1
    2
    3
    4
    5
    6
    56
    85
    24
    11
    120
    114
    I want to display the data as follows
    col1 / col2 / col3
    1 / 2 / 3
    4 / 5 / 6
    11 / 24 / 56
    85 / 114 / 120
    Can anyone Help me?

    I hope there might be some simple way to do this and waiting for experts to reply.
    Try the below query.
    SQL> select * from random_numeral;
      NUMERALS
             1
             2
             3
             4
             5
             6
            56
            85
            24
            11
           120
      NUMERALS
           114
           100
           140
    14 rows selected.
    SQL> select a.numerals ||' / '||b.numerals||' / '||c.numerals from
      2          (select numerals,rownum rn1 from
      3          (
      4              select numerals,mod(row_number() over(partition by 1 order by numerals),3)
      5              from random_numeral
      6          )
      7          where rn=1) a,
      8          (select numerals,rownum rn1 from
      9          (
    10              select numerals,mod(row_number() over(partition by 1 order by numerals),3)
    11              from random_numeral
    12          )
    13          where rn=2) b,
    14          (select numerals,rownum rn1 from
    15          (
    16              select numerals,mod(row_number() over(partition by 1 order by numerals),3)
    17              from random_numeral
    18          )
    19          where rn=0) c
    20  where   a.rn1=b.rn1(+)
    21  and b.rn1=c.rn1(+)
    22  /
    A.NUMERALS||'/'||B.NUMERALS||'/'||C.NUMERALS
    1 / 2 / 3
    4 / 5 / 6
    11 / 24 / 56
    85 / 100 / 114
    120 / 140 /
    SQL>Cheers,
    Mohana

  • How to insert code conditions ina QUERY

    Hi All,
    I'm creating a Query to extract the data from EKKO, EKPO and EKKN.
    here I have to insert a piece of code as checking below.
    IF EKPO-KNTTP ne '   '.      "not equal to blank
    extract the data from table EKKN.
    ENDIF.
    here I need your help like how to write this code in a Query.
    Thanks,
    Sunil Bodda.
    Edited by: sunil bodda on Apr 15, 2009 12:05 PM

    Hi Sunil,
    You need to code it in infoset. follow the steps below.
    1. Goto SQ02, enter your infoset.
    2. Click on "Extras" button(above find button). On the next page you will find a "Code" tab. 
    3. Declare a constant as space. choose DATA in the drop down for coding section.
    4. Choose "Record processing" or if any other appropriate choice from the drop down in the coding section.
    5. CHECK EKPO-KNTTP EQ c_space. and write your code here.
    Hope this helps.

  • How to put this start page back?

    how can i put this startpage as my default when i open tabs in safari?

    Safari > Preferences > General
    New windows open with:
    New  tabs open with:
    Select Top Sites instead of Homepage.

  • How to put Two condition at once

    Dear all
    I am combining two file here for the calculation, but the proble is that i have given a condition when colulm 4 of file-1 and column -2 of file are same then make calculation,, 
    But i want put a condition when column 4 of file -1 is identical with column 2 of file-2, and column 3 of file-1 is identical with colum -3 of file2 then make calculation,
    here i ahve attache my programme and files
    Thanks and regards
    Prince
    Attachments:
    test fiel-1.txt ‏99 KB
    test-2.txt ‏2 KB
    test.vi ‏29 KB

    Simply use an "AND" node:
    Regards,
    Even
    Certified LabVIEW Associate Developer
    Automated Test Developer
    Topro AS
    Norway

  • How to achieve this Calculaction in Query Designer

    Hi Experts
    Could you please update me on How can i acieve this calculaction...
    I had 2 KFs & 1 Formula (% Calculaction) in my Report
    Col A--Col B---Col C (%)-----
    R1----32 50%--
    R2----23(-33%)--
    R3----141217%--
    R4----161060%--
    Over
    all
    Result352729%--
    Col C = Col A % Col B
    In my Query  i had a condition on Col C
    Show Col C >0
    Then output of query is
    Col A--Col B---Col C (%)-----
    R1----32 50%--
    R3----141217%--
    R4----161060%--
    Over
    all
    Result352729%--
    THE OVERRESULT IS NOT CHANGING
    MY requirment is to achieve overresult for above query output
    Over
    all
    Result332437%--
    I can managed to get the Overall result for Col A & Col B in the Properties>Calculactions>Calculate result As-->Total
    What setting i have to make to change Col C Overall result
    Thanks

    Hi,
    I think that deactivating the condition and using a formula instead will work.
    Try e.g. this formula for Col C:
    ( 'Col A' % 'Col B' > 0 ) * ( 'Col A' % 'Col B' )
    You might also want to activate zero suppression in the report.
    Hope it helps.
    BR
    Stefan

  • How can achieve this (Condition on CHARS at cube or report level)

    HI,
    My report requirement is to display only values where employee Home Dept Not Equal To Worked Department.
    Home Department (CHAR-20) and
    Worked Dept (CHAR-20)
    For that I created a Info Object in Cube (ZINDICATOR).While data load i want to populate this field with ‘X’ (Flag) if Home Dept = Worked Dept and ‘Y’ (Flag) if Home Dept <> Worked Dept.
    So that I can use ZINDICATOR in Query Filter to restrict accordingly..
    When I tried to write an if condition in update/Transfer rules it is giving me error...
    <b>“Formula element is not allowed here”</b>
    How can I achieve my desired results......?

    OK sorry,
    Are you doing this in an individual update rule or in a start routine?
    I suggest start routine. Steps:
    1. Add your derived characteristic into the communication structure of the transfer rules (do not have any update in the transfer rules for it)
    2. In the update rules have a direct mapping for the characteristic.
    3. Create a start routine in the update rule. code should be something like
    FIELD-SYMBOLS: <f_dp> TYPE data_package_structure.
    LOOP AT DATA_PACKAGE ASSIGNING <f_dp> .
      IF <f_dp>-home_dpt eq <f_dp>-work_dpt.
         <f_dp>-/bic/zindicator = 'X'.
      ELSE.
         <f_dp>-/bic/zindicator = 'Y'.
      ENDIF.
    ENDLOOP.
    You will need to replace the work_dpt and home_dpt etc. bits with the names of your characteristics.
    Regards
    Peter

  • How to put two conditions (rendered) in a panelGrid

    I have two conditions to renderize a panelGrid, how I declare that? I tried to put two rendered but it didn't work. I tried a lot of things, nothing worked.
    Here is one of the codes I tried:
    <h:panelGrid styleClass="boxForm" columns="1"
    rendered = "#{!DHCPMainBean.newParameterDhcp} "
    rendered = "#{DHCPMainBean.newGroup}">

    Your code throwed the following error:
    javax.servlet.ServletException: ServletException in '/network/dhcpMain.jsp': java.lang.String
    I tried another forms like this:
    <h:panelGrid styleClass="boxForm" columns="1"
    rendered= "#{!DHCPMainBean.newParameterDhcp && DHCPMainBean.newGroup} ">throwed this error:
    javax.servlet.ServletException: ServletException in '/network/dhcpMain.jsp': /network/dhcpMain.jsp(135,46) The entity name must immediately follow the '&' in the entity reference.
    I tried this other:
    <h:panelGrid styleClass="boxForm" columns="1"
    rendered=
    "#{!DHCPMainBean.newParameterDhcp&DHCPMainBean.newGroup;}">But, it didn't work either:
    javax.servlet.ServletException: ServletException in '/network/dhcpMain.jsp': /network/dhcpMain.jsp(136,57) The entity "DHCPMainBean.newGroup" was referenced, but not declared.

  • How to use many conditions in query

    Hi all,
    i have a situation,must prepare a report to find availability of it devices.they are given the specific ip of devices.
    my query
    SELECT 
     Resultdate, [SERVICE]  ,[SERVICE TYPE] ,[IP]
    , DailyAvailability
      FROM [Orion].[dbo].[DepartmentNodesNew] t1
    left join (   select round(1-(sum([DownTimeMin])/(1440*count(*))),4)*100  as DailyAvailability,
      count(*) as Node,   c2.ResultDate  ,[Departament]  ,[IPAdress]
       from  [Orion].[dbo].[OrionEventsNodeDownTime] as c2 group by  [Departament] ,[IPAdress] , c2.ResultDate) t2
       on t1.IP=t2.IPAdress 
       where t2.DailyAvailability is not null and t1.SERVICE='SAP CRM' and t2.ResultDate='2014-12-10'
        order by ResultDate
    now how can i calculate the daily availability of sap crm which have 2 servers and they are in cluster,when one is down service is ok.when both of them are down service is off. how can i calculate by writing conditions.
     case when  ([SERVICE]='SAP CRM' AND [SERVICE TYPE]= 'DB Server' and [DownTimeMin] =0) then DBAvailability 100
      else  then DBAvailability select round(1-(sum([DownTimeMin])/(1440*count(*))),4)*100 ???

    SELECT Resultdate
    ,[SERVICE]
    ,[SERVICE TYPE]
    ,[IP]
    ,DailyAvailability
    INTO #TempTable
    FROM [Orion].[dbo].[DepartmentNodesNew] t1
    LEFT JOIN (
    SELECT round(1 - (sum([DownTimeMin]) / (1440 * count(*))), 4) * 100 AS DailyAvailability
    ,count(*) AS Node
    ,c2.ResultDate
    ,[Departament]
    ,[IPAdress]
    FROM [Orion].[dbo].[OrionEventsNodeDownTime] AS c2
    GROUP BY [Departament]
    ,[IPAdress]
    ,c2.ResultDate
    ) t2 ON t1.IP = t2.IPAdress
    WHERE t2.DailyAvailability IS NOT NULL
    AND t1.SERVICE = 'SAP CRM'
    AND t2.ResultDate = '2014-12-10'
    ORDER BY ResultDate
    SELECT Resultdate
    ,[SERVICE]
    ,[SERVICE TYPE]
    ,[IP]
    ,DailyAvailability
    ,CASE
    WHEN (
    [SERVICE] = 'SAP CRM'
    AND [SERVICE TYPE] = 'DB Server'
    AND [DownTimeMin] = 0
    THEN 100
    ELSE round(1 - (sum([DownTimeMin]) / (1440 * count(*))), 4) * 100
    END AS 'DBAvailability'
    FROM #TempTable
    -Vaibhav Chaudhari

Maybe you are looking for

  • Application Express Install - Login and images don't work

    I followed the instructions (as best I understood them) to install Apex on my database, and then setup an Oracle HTTP server to work with it. The problems I have are: When i goto the "first" page, which for me is: http://tomcatvs01.traxusers.com:7777

  • IPad keeps freezing when using iplayer

    I have just updated my iPad to 4.2 and since then when using iplayer the screen freezes after about 3-5 minutes. I have cleared both cookies and cache from the settings menu and this has made no difference!? Very frustrating when you've jst started t

  • Zcm 10.3 beta3 new action tab

    Hi, I'm normally working on 10.2.2 and now i have installed 10.3 beta3 in a test environment. To check the new options. I see that there is a NEW TAB added to the bundles. Normally you have. install/launch/uninstall/verify etc. Now i see a tab called

  • Updated Firefox and lost all toolbars, Hotmail, EVERYTHING!! How do I fix this?

    Updated Firefox last evening. Got up this morning to a whole new page on the computer. Clicked on Firefox and got a blank page with just a Firefox logo and a Google search line. There are no toolbars for me to use to get to my e mail, pictures or oth

  • IE Bugs

    http://www.san-juan-island.net/testSite I use dreamweaver the Missing Manuel, Adobe DW CS5 with PHP to create this site plus JavaScript the Missing Manuel. I was checking all the browsers to make sure the site was running correctly. All was fine unti