How to  use data function using characterstics variable for calculation on

how to  use data function using characterstics variable for calculation on  attribute as key figure

Hi Gayatri
Did you not see my answer for CASE because CASE does indeed offer the use of the BETWEEN clause, but DECODE does not. Let me give you a little synopsis of DECODE.
In its most simple form it takes 4 values and looks like this: DECODE(A, B, C, D)
This essentially means, IF A = B THEN C ELSE D
The trick to solving BETWEEN in a DECODE is to work out algoriths where A = B. Because we don't know how many values are between 00 and 99, although I could guess there were 100 we could of course have 100 parts in the DECODE but that would be awful. How about if we look at it another way and say this:
IF PART_NUMBER < 'SDK00' THEN pay_amount
ELSE IF PART_NUMBER > 'SDK99' THEN pay_AMOUNT
ELSE pay_amount + 100
This statement only had 2 hard coded values, but how to make DECODE work with less than? Easy, we use the LEAST function. The LEAST function takes 2 values and returns the one with the lowest value. So I use LEAST(PART_NUMBER, 'SDK00') then whenever the PART_NUMBER is lower than SDK00 it will be true. A similar situation exists for the opposite function GREATEST. Putting all of this together then, you can do this:
DECODE(PART_NUMBER, GREATEST(PART_NUMBER, 'SDK00'), DECODE(PART_NUMBER, LEAST(PART_NUMBER, 'SDK99'), PAY_AMOUNT * 100, PAY_AMOUNT), PAY_AMOUNT)
In English this can be read as follows:
IF the PART_NUMBER is greater than or equal to SDK00 and the PART_NUMBER is less than or equal to SDK99 THEN PAY_AMOUNT x 100 ELSE 0
Best wishes
Michael

Similar Messages

  • How to use date functions in BPEL

    Hi All,
    Is there any wayout for calculating no. of years with a given date and current date in BPEL.
    I am developing a small application where I have to calculate the years of experience of the employees. I am given with the date of joining.I want to subtract the date of joining from the current date. Is there any way-out to calculate no. of years from the given date and current date in BPEL using date functions or something else.
    Please suggest something..
    Thanks in Advance
    Roshni Shankar

    you could use something like this in xsl
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
         <xsl:output method="xml"/>
         <xsl:variable name="date1" select="xs:date('2001-01-01')"/>
         <xsl:variable name="date2" select="xs:date('2010-01-10')"/>
         <xsl:variable name="dif" select="$date2 - $date1"/>
         <xsl:template match="/">
         <all>
              <date1>
                   <xsl:value-of select="$date1"/>
              </date1>
              <date2>
                   <xsl:value-of select="$date2"/>
              </date2>
              <dif-days><xsl:value-of select="fn:days-from-duration($dif)"/></dif-days>
              <dif-years1><xsl:value-of select="fn:years-from-duration($dif)"/></dif-years1> <!-- gives 0 for me -->          
              <dif-years2><xsl:value-of select="fn:days-from-duration($dif) div 356"/></dif-years2>                    
              </all>
         </xsl:template>
    </xsl:stylesheet>

  • How to extract data by using function module in generic extraction please

    how to extract data by using function module in generic extraction please  give me steps  required

    Dear Deba,
    Generic Extraction via Function Module
    /people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
    If the requirement is like extracting data from multiple tables with some complex logic then views cannot be used..so u cna go for FM is used where it can be achieved.
    Chk these
    /people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a0f46157-e1c4-2910-27aa-e3f4a9c8df33
    check the following thread
    generic extraction with function module
    Generic Extraction with function module
    Regards,
    Ram.

  • Explain how to implement prompt functionality using @variable

    Hi all,
    Anyone please explain how to implement prompt functionality using @variable.
    We got some sql reports.Those reports have to be converted into BO free hand sql report.
    Please provide any best practices for converting sql reports into BO free hand SQL.
    Thanks & Regards,
    James Charle

    Hi
    Please refer "@Variable" section  in page number 601, in http://help.sap.com/businessobject/product_guides/boexir31SP3/en/xi31_sp3_designer_en.pdf
    Regards
    Ashwini

  • Queries with date functions using PreparedStatement for multiple DB

    I am developing application that uses DB independant queries. I am using preparedstatement to process the queries. I need to use date functions for query selection criteria.
    for eg.
    selecting the list of employees who had joined in the last 15 days
    selecting list of employees who had joined between two dates etc.
    where Date Joined field is a Timestamp value. To extract date no DB specific function can be used.
    If I use setMonth, setYear etc.. to set params in the pstmt the query becomes complex in the above case. Can any one throw some light on how to do the above in preparedstatement or any other better alternative.
    Tx a lot

    Hi,
    I did not mean that way. I presume that there is a timestamp value (may be a date too) column in the table. Then based upon your requirement (say before 15 days) pass the value as date (or time stamp) in the query as a parameter.
    String qry = "select * from myTable where join_date <= ?";
    stmt.setDate(1,myDate); // this is where you will have to manipulate the value to suit your DB timestamp or date value; you will have compatibility issues with util.Date and sql.Date so use Calendar class to satisfy.Feel free to mail me if you need further clarifications to [email protected]
    Cheers,
    Sekar

  • Give me detail functions  use boolean function,  use  detail

    give me detail functions  use boolean function,  use  detail func in calculated key figure

    Hi,
    Adding to that some more few links which helps you are
    Defining Formulas:[http://help.sap.com/saphelp_nw70/helpdata/EN/71/0aec3b6e011341e10000000a114084/content.htm]
    Percentage Functions:[http://help.sap.com/saphelp_nw70/helpdata/EN/e2/16f13a2f160f28e10000000a114084/content.htm]
    Data Functions:[http://help.sap.com/saphelp_nw70/helpdata/EN/e2/16f13a2f160f28e10000000a114084/content.htm]
    Boolean Operators:[http://help.sap.com/saphelp_nw70/helpdata/EN/23/17f13a2f160f28e10000000a114084/content.htm]
    Technicle Notes About Formula Operators:[http://help.sap.com/saphelp_nw70/helpdata/EN/37/b4393ccab19b57e10000000a114084/content.htm]
    Defining Restricted Key Figures :[http://help.sap.com/saphelp_nw70/helpdata/EN/61/d0b143aa26b849b4e79a859ea1d7d1/content.htm]
    Defining Calculated Key Figures :[http://help.sap.com/saphelp_nw70/helpdata/EN/13/e072abaddb574284d22361f0b824bf/content.htm]
    [http://help.sap.com/saphelp_nw70/helpdata/EN/d3/8057f830a911d4b2be0050dadfb23f/content.htm]
    [http://help.sap.com/saphelp_nw70/helpdata/EN/d7/c70540ba5ee569e10000000a155106/content.htm]
    Regards,
    Rajkandula

  • How to Change String back to math symbol for calculation??

    Hi,
    How to Change String back to math symbol for calculation to achieve this coding. it's for a for loop
    int a;
    String sym0 = "+";
    String sym1 = "-";
    String sym2 = "*";
    String sym3 = "/";
    for (int i=0; i<=3; i++)
    a = 45 sym0 74;
    }

    There is no method to achieve this...aa far as I am aware of.

  • How to use  date function in my procedure

    hi Gurus,
    i have a requirement
    where user passes the end_date parametre from front end which get convered to
    End Date => 2012/05/31 00:00:00
    now i based on this end date value i have to calculate the start date which is only month less than the end date, i know i can use add_months function for this requirement but
    my problem is
    l_start_date :=add_months(fnd_date.canonical_to_date(p_end_date),-1);
    (OR)
    l_start_date := add_months(to_date(end_date,'DD-MON-YYYY'),-1);
    all these are returning date format as DD-MON-YYYY eg;
    if user passes from front end 31-may-2012 , in the backend to my procedure it is passing as 2012/05/31 00:00:00
    and my procedure calculating start date and returning as '01-MAY-12',
    but my requiremnt is
    it should return
    Start Date => 2012/05/01 00:00:00
    any pointers on this is highly appreciable,
    thanks in advancee

    HuaMin Chen wrote:
    BluShadow wrote:
    HuaMin Chen wrote:
    Try
    select trunc(to_date('22-AUG-03'), 'MONTH') from dual;?? That is so wrong.
    Is that date 22nd August 2003? 22nd August 1903? 3rd August 2022? 3rd August 1922?
    You have no date format specified in your to_date function.That is fine for 10g or above versions. Thank you.It way work, if you're lucky, but it depends on your sessions NLS settings...
    SQL>  select trunc(to_date('22-AUG-03'), 'MONTH') from dual;
    TRUNC(TO_DATE('22-AU
    01-AUG-0003 00:00:00
    SQL> alter session set nls_date_format = 'YYYY-MM-DD';
    Session altered.
    SQL>  select trunc(to_date('22-AUG-03'), 'MONTH') from dual;
    TRUNC(TO_D
    0022-08-01
    SQL> alter session set nls_date_format = 'HH:MI:SS YYYY-MM-DD';
    Session altered.
    SQL>  select trunc(to_date('22-AUG-03'), 'MONTH') from dual;
    select trunc(to_date('22-AUG-03'), 'MONTH') from dual
    ERROR at line 1:
    ORA-01849: hour must be between 1 and 12
    SQL>So it's certainly not "fine". It's bad practice.
    This must be fine
    select trunc(to_date('22-AUG-03','dd-MON-RR'), 'MONTH') from dual;That's better.

  • How to use the dynamical or static variable for ESSBASE cube name?

    Hi Experts,
    When I import ESSBASE Cube into physical layer, the cube name from ESSBASE is created automatically, such as H_Sales.
    I want to use the the static or dynamical variable for replacing the external name. So I try to create the static variable in RPD,such as cubeName, and use the following code
    'VALUEOF(cubeName)' into the textbox of external name.
    However, when I view the report in answer, it will generate the error message: Database VALUEOF(cubeName) does not exist.
    Is it possible to implement this functionality?
    Thanks..

    Hi,
    use <%=odiRef.getSchemaName("D")%>
    D as parameter if it is the Data Schema or W if you need the schema from Work Schema
    Your command will be like:
    select <%=odiRef.getSchemaName("D")%>.GER_LOT_EXEC_ODI('Fluxo', 1, 'C') FROM DUAL
    Works?
    Cezar Santos
    http://odiexperts.com

  • How to define Excel function using BEx formula

    Hi experts,
    May I know how to define the following Excel function using BEx formula?
    IF(AND(Revenue<0,Cost<0),"N/A",(Profit/Lost/ABS(Revenue)))
    Thanks!

    for me its easy to implament logic with * and + rather than  AND and OR respectively
    ((Revenue<0)(Cost<0))Value +((Revenue>0)(Cost>0)) ( Profit&Lost / ABS(Revenue))
    As i have mentoned already,for Else case i have considered (Revenue>0) and (Cost>0)  only.
    Value can be a KeyFigure/Formula/formula variable/CKF/RKF
    its not possible to type characters in the formula window so 'N/A'
    Regards.
    Message was edited by:
            Murali c

  • Running Total (or) Moving Sum (or) Rollup using Date functions

    I have to pass the Begin date and End date using prompt in my application (for daily basis for one month, monthly and yearly).
    How can i use the date function for Rollup the days values(running total) for the below mentioned SQL
    Table.Date field (@Prompt('Begin_Date','D',,mono,free) and @Prompt('End_Date','D',,mono,free)
    @prompt automatically takes the begin date and end date.
    I need the sql for rollup(running total) on daily basis for one month say jan 1 to jan 31.
    Any idea?

    Check the Oracle on-line documentation on the ROLLUP option of the GROUP BY clause. It should be able to give you running totals.

  • Using pipelined functions with bind variables in Apex...

    Hy all:
    I have a table which has about 10 million records and it is hanging up the system when it is trying to retrieve the data from that table... so what I have done is I created a pripelined
    function and then trying to retrieve data using an SQL statement ... when I try to use a bind variable to filter by the date and location it is binding according to the location
    but not by date ... can anyone help me in this please!!
    Help greatly appreciated !
    Thanks in advance !

    Hi Denes:
    Create or replace type ohe1 as object (
    IMLITM NCHAR(50), IMAITM NCHAR(50), IMDSC1 NCHAR(60), COUNCS NUMBER(22), LIPQOH NUMBER(22),
    LIMCU NCHAR(24), LILOCN NCHAR(40), LILOTN NCHAR(60), LILOTS NCHAR(2), IOMMEJ NUMBER(22))
    CREATE OR REPLACE TYPE OHE AS TABLE OF Ohe1
    CREATE OR REPLACE FUNCTION GET_ohe
    return OHE PIPELINED
    IS
    m_rec ohe1:= ohe1 (NULL,NULL,NULL,0,0,NULL,NULL,NULL,NULL,0);
    begin
    for c in (select f1.LITM LITM, F1.AITM AITM, F1.DSC1 DSC1, F5.UNCS UNCS,
    F21.QOH QOH, F21.MCU MCU, F21.LOCN LOCN, F21.LOTN LOTN, F21.LOTS LOTS,
    F8.MEJ MEJ FROM F1 F1, F2 F2, F21 F21, F5 F5, F8 F8
    WHERE (F5.EDG='07') AND (F21.QOH != 0) AND F2.IBITM = F1.IMITM
    AND F21.ITM = F2.ITM AND F21.ITM = F5.ITM AND F21.MCU = F5.MCU
    AND F21.MCU = F2.MCU AND F21.LOTN = F8.LOTN AND F21.MCU = F8.MCU)
    loop
    m_rec.LITM:=c.LITM;
    m_rec.AITM:=c.AITM;
    m_rec.DSC1:=c.DSC1;
    m_rec.UNCS:=c.UNCS;
    my_record.QOH:=c.QOH;
    my_record.MCU:=c.MCU;
    my_record.LOCN:=c.LOCN;
    my_record.LOTN:=c.LOTN;
    my_record.LOTS:=c.LOTS;
    my_record.MEJ:=c.MEJ;
    PIPE ROW (my_record);
    end loop;
    return;
    end;
    select LITM , AITM , DSC1 , UNCS*.0001 UNCS, QOH*.0001 QOH, (UNCS*.0001)*(QOH*.0001) AMOUNT,
    MCU MCU, LOCN LOCN, LOTN LOTN, LOTS LOTS, jdate(DECODE(MEJ,0,100001,MEJ)) MEJ FROM
    TABLE (GET_ohe)
    WHERE trim(LIMCU)= TRIM(:OHE_BRANCHID)
    AND (jdate(DECODE(MEJ,0,10001,MEJ)) >=:FROMEXPDT
    AND jdate(DECODE(MEJ,0,10001,MEJ)) <=:TOEXPDATE)
    The MEJ is a julian date and I am trying to convert it into a date ..... using the function jdate! and the pipelined function is created without any errors
    and I am able to get the data with correct branch location bind variable but only problem is it is not binding the date filters in the sql.....
    Thanks
    Edited by: user10183758 on Oct 16, 2008 8:17 AM

  • Print a DayName without using Date functions

    Hi,
    I have an assignment like without using any date functions i should print a calendar.
    Below is the code without using any datefunctions like dateadd, datediff, datename a calendar has been generated for month and year entered. I want a week name for the dates like sunday ... monday etc. 
    I can take any date from calendar as reference  and calculate based on that date.
    ex: today is 2/20/2014 thursday . Next 7days again will be thursday, same way before 7days will be thursday.
    I need to loop in below procedure and get weekname. 
    Plz help in the code,
    I am using SQL server 2008
    IF OBJECT_ID ('dbo.Calendar1') IS NOT NULL
         DROP PROCEDURE dbo.Calendar1
    GO
    CREATE  PROCEDURE [dbo].Calendar1 --4,1991
       @month int,
       @Year  int
     AS  
     BEGIN
     declare 
     @startdateofMonthYear date,
     @EnddateofMonthYear Date
    Set @startdateofMonthYear=(Select cast(@Year as varchar(4)) +'-'+Right('00'+Cast(@month as varchar(2)),2) +'-'+'01')
    Set @EnddateofMonthYear = (SELECT case when @month IN (1,3,5,7,8,10,12) then cast(@Year as varchar(4)) +'-'+Right('00'+Cast(@month as varchar(2)),2) +'-'+'31'
    when @month IN(4,6,9,11) then cast(@Year as varchar(4)) +'-'+Right('00'+Cast(@month as varchar(2)),2) +'-'+'30'
    else  cast(@Year as varchar(4)) +'-'+Right('00'+Cast(@month as varchar(2)),2) +'-'+(CASE WHEN (@YEAR % 4 = 0 AND @YEAR % 100 <> 0) OR @YEAR % 400 = 0 THEN '29' else '28' End) 
    End) 
    ;WITH CTE_DatesTable
    AS
    Select 1 daysint, Cast(SUBSTRING(cast(@startdateofMonthYear as varchar(20)),1,7) + '-'+CAST(1 as varchar(2)) as DATE) Calendardates
    UNION ALL
    SELECT   daysint+1,Cast(SUBSTRING(cast(@startdateofMonthYear as varchar(20)),1,7) + '-'+CAST(daysint+1 as varchar(2)) as DATE) Calendardates
    FROM CTE_DatesTable
    WHERE  daysint<= 
    (SELECT case when @month IN (1,3,5,7,8,10,12) then 31
    when @month IN(4,6,9,11) then 30
    else  (CASE WHEN (@YEAR % 4 = 0 AND @YEAR % 100 <> 0) OR @YEAR % 400 = 0 THEN 29 else 28 End) 
    End)-1
    Select 
    [DWDateKey]=Calendardates,
    [DayDate]=daysint,
    [MonthNumber]=@Month,
    [MonthName]=Case when @month = 1 then 'January'
     when @month  = 2 then 'February'
     when @month  = 3 then 'March'
     when @month  = 4 then 'April'
     when @month  = 5 then 'May'
     when @month  = 6 then 'June'
     when @month  = 7 then 'July'
     when @month  = 8 then 'August'
     when @month  = 9 then 'September'
     when @month  = 10 then 'October'
     when @month  = 11 then 'November'
     when @month  = 12 then 'December' 
    End,
    [Year]=@Year
    From CTE_DatesTable
    END
    bhavana

    In the above code, where do i pass the year and month?
    (Select 2000 YearID
    Union All
    Select YearID +1 From cte where YearID <2100
     In above condition from 2000 year its displaying.
    If i want in 90's year , Day name will not be correct.
    Deepa

  • How to convert date without using conversion exit?

    hi!! Guys,
         please can anybody help me how to compare date which is not in actual format
    i.e. (when comparing  BKPF-budat with TCURR-gdatu in where condition of a Select query its giving syntax error  "when you use the addition 'fOR ALL ENTRIES IN itab' the fields gdatu and it_bkpf-budat" must have the same type and the same length. its very urgent...
    thanks in advance.
    akanksha.

    try like this.
    data : year(4),
             mon(2),
    day(2).
    in itab declare field cbudat(8) type c.
    loop at itab.
    year = itab-budat(4).
    mon = itab-budat+4(2).
    day = itab-budat+6(2).
    concatenate year mon day into itab-cbudat.
    modify itab.
    endloop.
    now use select for all entries and check gdatu = itab-cbudat.
    regards
    shiba dutta

  • How to consolidate data files using data pump when migrating 10g to 11g?

    We have one 10.2.0.4 database to be migrated to a new box running 11.2.0.1. The 10g database has too many data files scattered within too many file systems. I'd like to consolidate the data files into one or two large chunk in one file systems. Both OSs are RHEL 5. How should I do that using Data Pump Export/Import? I knew there is "Remap" option could be used, but it's only one to one mapping. How can I map multiple old data files into one new data file?

    hi
    datapump is terribly slow, make sure you have as much memory as possible allocated for Oracle but the bottleneck can be I/O throughput.
    Use PARALLEL option, set also these ones:
    * DISK_ASYNCH_IO=TRUE
    * DB_BLOCK_CHECKING=FALSE
    * DB_BLOCK_CHECKSUM=FALSE
    set high enough to allow for maximum parallelism:
    * PROCESSES
    * SESSIONS
    * PARALLEL_MAX_SERVERS
    more:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28319/dp_perf.htm
    that's it, patience welcome ;-)
    P.S.
    For maximum throughput, do not set PARALLEL to much more than twice the number of CPUs (two workers for each CPU).
    Edited by: g777 on 2011-02-02 09:53
    P.S.2
    breaking news ;-)
    I am playing now with storage performance and I turned the option of disk cache (also called write-back cache) to ON (goes at least along with RAID0 and 5 and setting it you don't lose any data on that volume) - and it gave me 1,5 to 2 times speed-up!
    Some says there's a risk of lose of more data when outage happens, but there's always such a risk even though you can lose less. Anyway if you can afford it (and with import it's OK, as it ss not a production at that moment) - I recommend to try. Takes 15 minutes, but you can gain 2,5 hours out of 10 of normal importing.
    Edited by: g777 on 2011-02-02 14:52

Maybe you are looking for