Rounding to 2 decimal places in Derived column transform editor

I want to replace the contents of a value column with itself but rounded to 2 decimal places.
The current column is a double and I have tried to perform this using the following expression but it fails to work.
Code Snippet
Round(cc_vl,2)
How should I achieve this?

I’ll take a guess here but you started with this –
123.45678
Got this –
123.45000
Wanted this –
123.45
So the 123.45000 is absolutely correct, the value has been rounded to 2 digits. A double however has a scale greater than 2, and you only wanted two digits after the point because you were concerned about how the value looked rather than the actual value. This is certainly not a bug. It is how you format the data for display.
Your solution is the way to do this, either on the Derived Column or Data Conversion Transformation. You got it in the end, the replace versus new, because you cannot change the type of a column. You may convert the value, but the storage type of the column means it will implicitly revert to the base column type when you put it back, albeit with a value that has been rounded.
Does that explain it?

Similar Messages

  • Derived Column Transformation Editor and a Date

    My vendor file used to have "N/A" in the Date field and I used a Derived Column Transformation Editor to feel this out with the following expression...
    PAPER_STOP_DATE == "N/A" ? NULL(DT_WSTR,50) : PAPER_STOP_DATE
    Now the vendor has also decided to pass nothing in there. So I honestly don't know if it's a "" or a <NULL>. It's coming from an Excel spreadsheet.
    Is there any easy way to add "" to this expression and how? Or is there a way to determine if this field is a proper date format?
    This is the date that exists in the cell...
    03-aug-2014
    After I determine if it is a "N/A", I am doing a Data Conversion on it and it is properly loading to our SQL Server Database.
    Thanks in advance for your review and am hopeful for a reply.
    ITBobbyP85

    If i understand correctly you want to derived a column to NULL if the input "paper stop date" is "N/A" or "" or a NULL else the actual "paper stop date". Right ?
    PAPER_STOP_DATE == "N/A" || TRIM(PAPER_STOP_DATE) == "" || ISNULL(PAPER_STOP_DATE)   ? NULL(DT_WSTR,50) : PAPER_STOP_DATE
    Regards, RSingh

  • Rounding to 2 decimal places

    When using Math.round, I know to round to 2 decimal places it would be Math.round(variable * 100.0)/100.0. I have this in one program and it works. (answer = Math.round(answer*100.0)/100.0;) I have it in another program and it doesn't (double answer = Math.round(balances [looper]*100.0)/100.0;// balances is declared as double balances [] = new double [numberOfCustomers];) What am I doing differently that I should be looking for.

    Hi,
    Please try using java.text.DecimalFormat class. This class is a subclass of java.text.NumberFormat. You can read about this class from JDK documetation.
    HTH
    VJ

  • Derived column transformation from varchar(8) YYYYMMDD to DATETIME column

    It seems I have tried everything, but all I need to do is change a column from varchar(8) to DATETIME. Some lines are blank, zero length strings, and some have dates such as 20140829. All the rows go to an exception table or it just bombs altogether. The
    only thing I can get to run is NULL(DT_DATE), but obviously, that won't work in the end.
    I tried LTRIM(RTRIM(MyDateColumn) == "" ? (DT_DATE)"1900-01-01" : (DT_DATE)(SUBSTRING(MyDateColumn,1,4) + "-" + SUBSTRING(MyDateColumn,5,2) + "-" + SUBSTRING(MyDateColumn,7,2))
    I got truncation errors on that.
    Sometimes I got an error: An error occurred while attempting to perform a type cast.
    I tried DT_DATE, DT_DBDATE and DB_DBTIMESTAMP
    I even tried putting GETDATE() in there or a literal date such as "2014-08-29" like (DT_DBDATE)"2014-08-29"
    This wouldn't even compile: MyDatCeolumn == "" ? NULL(DT_DBDATE) : (DT_STR,10,1252)((DT_DBDATE)MyDateColumn)
    I tried many variations on these. I either got truncation errors or the transformation would turn red and stop, or the expression wouldn't work (turns red when you leave the row).
    Review:
    Source MyDateColumn VARCHAR(8) NULL; Target MyDateColumn DATETIME; Source values in format of "" (blank) or "20140829". The blanks should end up null, or maybe a literal date like Jan 1, 1900, and the actual dates should be transformed
    to DATETIME.
    Should not be that hard. Thanks in advance for help.

    Hi duanewilson,
    Please create a Derived Column transformation and a new column, then use the following expression for the expression field:
    (DT_DATE)(SUBSTRING([MyDateColumn],1,4) + "-" + SUBSTRING([MyDateColumn],5,2) + "-" + SUBSTRING([MyDateColumn],7,2))
    If you have any feedback on our support, please click
    here.
    Elvis Long
    TechNet Community Support

  • Round to two decimal places...and keeping trailing 0

    Ok, I have done a search on rounding. So I made this function:
        private double round(double number){
           double d = Math.pow(10, 2);
           return Math.round(number * d) / d;
        }However, if I use a number like 3.59999, it returns 3.6. For what I am using it for, I need it to return 3.60. Any ideas? Thanks.

    You normally only format for display! You seem to be wanting the default format to show 2 decimal places. This makes no sense. Internally a number(double or float) doesn't know about decimal places so how can the default format know you want 2 decimal places?
    For the most part you only need to worry about decimal places when you print a number using the DecimalFormat class.
    There are times when you might want to round values to 2 decimal places before doing more calculation. I have only met this when adding monetary values when it is important that a column total equals the sum of a displayed column values. In this case one uses something like the technique you originally proposed to round values before summing them. You then use DecimalFormat to display the values.

  • TIMESTAMPDIFF rounding to 2 decimal places instead of 0

    Hi,
    Requirement is to find difference between two timestamp column,
    as known one we cannot perform arithmetic operation in non number type in rpd.
    Hence tried using TIMESTAMPDIFF function as below,
    TimeStampDiff(SQL_TSI_MINUTE, MONITOR_TIMESTAMP, ATT_TIMESTAMP" )
    OBIEE server converting this function to below SQL ,
    ROUND( ( CAST(ATT_TIMESTAMP as DATE) - CAST(MONITOR_TIMESTAMP as DATE) ) * 1440 )
    this returns value as ex: 12 as rounded value without any decimal places.
    but we want to have two decimal places, how to fix this or any work around ?
    Thanks,
    Satheesh

    instead of * 1440
    do with
    * 1440.00
    btw: why you need to cast to date? why cant be timestamp?
    Discard it

  • Round to 2 decimal places

    hello guys,
    I have a table. One column of the table displays the scores.
    ex: 2.2222222233333
    2.32232323
    I want to round all the numbers in that column to 2 decimal.
    Result needed: 2.22
    2.32
    Can you please help me how can i get handle to the column and round the numbers to 2 decimal places.

    Boris,
    1) You mentioned "i tried finding out the VO", I am not sure how you checked it.
    Enable diagnostics then you will get a link in the Bottom left corner called "About this page",
    click on that , and expand it, you can see the page structure there, there you can find the attached VO with your table region.
    Or
    begin
    jdr_utils.printDocument('<your page path like /oracle/apps/per/....PG>');
    end;
    Which will give the PG.xml you can load the page in Jdeveloper(with the same package)
    and you can have a look at the page structure in the page, which will give details about what VO is attached to your table region.
    2) Yes you are right, you cannot round the null value
    3) What page you are trying to get round the value, is it the FinalAppraisalPG?
    Give me the full navigation,
    Thanks.
    With Regards,
    Kali.
    OSSI.

  • Rounding To Nearest Decimal Place

    Hey Flash Family,
    I am getting the correct output i want but is also giving me
    like 8 numbers after the decimal place...all i want is the numbers
    rounded to the nearest cent meaning only 2 numbers to the right of
    the decimal point....what do i need to add to the current code to
    correct this issue.
    Thanks N Advance

    attach that code to the first frame of your main timeline.
    then anytime you need to change the format of a number like
    _root.how.ROIM.val_tcost use:
    _root.return2DecPlaces(_root.how.ROIM.val_tcost);

  • Rounding to two decimal places in BPC/NW

    Hello,
    I am dealing with the task to round values to two decimal places. I have found some discussions in BPC-MS where the statement ROUND should work in logic. Unfortunately I am not able to make it work in the NW version.
    Isn't there also a parameter in the appset or application administration which would cut the numbers only to two decimal places (this task would be also a possible solution for us).
    Thanks for any help
    Jan

    Hello Pravin,
    the second import worked fine. I realized that the class has changed to ZCL_BPC_SL_ROUND.
    I debugged the class and noticed that the parameter it_cv is not filled at all. Therefore the program ends before starting the rounding procedure. Here is the part of the code:
    Take CV into account
      clear l_success.
      loop at it_cv into ls_cv.
        clear l_val_string.
        loop at ls_cv-member into l_member.
          if sy-tabix eq 1.
            l_val_string = l_member.
          else.
            concatenate l_val_string l_member into l_val_string separated by ','.
          endif.
        endloop.
        if l_val_string ne space.
          l_success = add_dim_restriction( i_param = l_val_string i_dimension = ls_cv-dimension i_clear = abap_true ).
          if l_success eq abap_false.
            concatenate 'Failed to successfully add Dimension' ls_cv-dimension into l_log_msg
            separated by space.
            cl_ujk_logger=>log( l_log_msg ).
            cl_ujk_logger=>log( 'Exiting Round Method' ).
            cl_ujk_logger=>empty_line(  ).
            raise exception type cx_uj_custom_logic
              exporting messages = et_message.
            exit.
          endif.
        endif.
      endloop.
      if l_success eq abap_false. exit. endif. - here the program exits and therefore doesn't do any rounding.
    If I comment this part the system rounds correctly but runs on all records in the cube which degrades performance a lot.
    Could you please advice further if it is possible to restrict the data region only to the submitted data?
    Best regards
    Jan

  • Rounding to 2 decimal place

    Hi,
    I am trying to round the decimal place of number 0.105 as .11.
    But it only rond up to 0.1 not 0.11.
    I don't understand why it doesn't round to 0.11.
    Can any one explain to me ?
    My code :
    import java.util.*;
    import java.text.*;
    import java.math.*;
    public class TestFile {
    public double number = .105;
    public static void main(String[] args) {
    TestFile test = new TestFile();
    DecimalFormat aFormat = new DecimalFormat("#.##");
    int decimalPlace = 2;
    double num = .105;
    BigDecimal bd = new BigDecimal(num);
    bd = bd.setScale(decimalPlace,BigDecimal.ROUND_HALF_UP);
    //DecimalFormat aFormat=new DecimalFormat("###.00");
    String formattedString = aFormat.format(test.number);//format the String entered
    System.out.println("formatted string: " + formattedString);
    System.out.println("big decimal " +bd.doubleValue());
    double formattedDouble = Double.parseDouble(formattedString);//convert to a double
    System.out.println("back to a double: " + formattedDouble);
    What should I do to round 0.11 ?
    Thanks,
    njan.

    BigDecimal bd = new BigDecimal(num);Change this line to
    BigDecimal bd = new BigDecimal(Double.toString(num));Read the notes in the API for BigDecimal constructor that accepts double.
    http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(double)
    The results of this constructor can be somewhat unpredictable...

  • Rounding to a decimal place

    like, right now i have this huge equation;
    double heatIndex8 = (-42.379) + (2.04901523 * birmingTemp[7]) + (10.14333127 * birmingHum[7]) - (0.22475541 * (birmingTemp[7] * birmingHum[7])) -
                             (6.83783 * Math.pow(10, -3) * Math.pow(birmingTemp[7], 2)) - (5.481717 * Math.pow(10, -2) * Math.pow(birmingHum[7], 2)) +
                             (1.22874 * Math.pow(10, -3) * Math.pow(birmingTemp[7], 2) * birmingHum[7]) + (8.5282 * Math.pow(10, -4) * birmingTemp[7] * Math.pow(birmingHum[7], 2))
                             - (1.99 * Math.pow(10, -6) * Math.pow(birmingTemp[7], 2) * Math.pow(birmingHum[7], 2))and it prints out an insane amount of decimal places...
    how can I tell the code to round(heatIndex8) to the tens place?

    paulcw wrote:
    Use a java.text.DecimalFormat, or one of the printf methods that are now all over the place. (Well, String and java.io.PrintWriter and PrintStream, in particular).
    By the way the size of the equation doesn't have a lot to do with it.
    Edited by: paulcw on Feb 2, 2008 1:23 PMI know it doesn't, but I just really hate it.
    decimal format you say? I'll go check that.

  • Rounding to 1 decimal place.

    Hello again.
    I have a method called "findTheAverage" which takes in an array of integers as a parameter and then calculates and returns the average as a float.
    What I want to do now though is create another method called "roundTheAverage" which takes in the float average variable from the previous method, rounds it to one decimal place, and then returns it as a float called roundedAverage.
    Could anybody help me in achieving this?
    Thanks.

    I'm fairly new to Java, hi.
    Oh I know all about you.
    I'm trying to write a method which takes in a float
    called "number" and then returns this float to two
    one decimal places called "roundedNumber".
    This is not the way this works. You have to write your own code.
    >
    Could you type me the code that I'd need to do this
    perhaps?
    Nope.
    It's a pretty simple problem I think, and it's
    wasting an enormous amount of time figuring it out.
    You are right on both counts. It is very simple and you are wasting alot of everyones time.
    >
    thanksAPI Application Programming Interface
    Javadoc API
    In context for this site means the documentation for the basic packages that make up the core Java API.
    I provided a link earlier to the Javadocs for java.text.DecimalFormat
    If you can't figure it out you need to HIRE A TUTOR.

  • Rounding to two decimal places

    In Java, how do I round a number off to two decimal places?
    Thank You

    java.text.DecimalFormat
    Or use java.math.BigDecimal and specify rounding rules, apparently.

  • Rounding to 2 decimal places WITHOUT using any formatting class

    Hello
    I'm trying to round a number (double) to 2 decimal places without using any of the formatting class like (DecimalFormat or Math.Round and BigDecimal). Is it possible to do it by just using typecast?

    OP:
    BigDecimal is not a formatting class. Math.round isn't a class at all.
    Typecasting doesn't really do that sort of thing at all (unless you count dropping fractional components when casting to an integer type).
    double holds values in binary format, so it's basically impossible to round to decimal values meaningfully.
    Chuck:
    I thought that BigDecimal supported arbitrary decimal precision, so one doesn't have to do that sort of thing....?

  • Rounding off the decimal place.

    how to round off to 2 decimal place for this following programs:
    double x;
    x = 5.0/3.0;
    System.out.println(x);
    answer for x is 1.6666666666666
    my desired output is 1.67

    import java.text.*;
    public class Foo {
        public static void main(String[] args) {
            double x;
            x = 5.0 / 3.0;
            DecimalFormat df = new DecimalFormat("0.##");
            System.out.println(df.format(x));
    }

Maybe you are looking for

  • Upgraded to Mountain Lion, can no longer use airplay

    Last week I purchased Apple TV (I believe its 3rd Gen) and had it all working fine, until I decided to be 'clever' and upgrade to Mountain Lion so I could use the mirroring in AirPlay. Prior to the upgrade I could stream brilliantly through itunes, i

  • I'm new to mac book pro need help with the dock

    'm new to mac book pro and I accidentally delete from the dock the Utilities and Documents Icon. How do I put it back? I already tried moving from

  • ORA-06553: PLS-123: program too large on import

    Hi, I import a dump file from a 9.2.0.4 to an other 9.2.0.4 database. On some importing table, I have this error : . . importing table           "PS_TL_PAYABLE_HIST"          0 rows imported IMP-00017: following statement failed with ORACLE error 654

  • Req Help to Update LIKP-LIFSK,Delivery Header block through custom program.

    Hi everyone, Can you please suggest a FM or BAPI to update the delivery header block field, LIFSK, in LIKP table through FM or a BAPI. I tried using 'BAPI_OUTB_DELIVERY_CHANGE' as below to update the LIKP-LIFSK, but it is not working. DATA : ls_likp

  • Fade in

    i have a splash screen i want to use. i would like to click on a link or somthing and it would open a window with the image there, however i want tyhe window to fade in is this possable?? i dont see why we couldnt make the image fade in instead of th