Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: how can i trim the decimal part of a number.

  1. #1

    Exclamation how can i trim the decimal part of a number and how to add two numeric values

    Suppose after calculating sum of items we get 31.55

    but i want to display this as 31 only.

    SO how is this possible.

    IN this I want to trim the decimal part of the number.

    IS that possible???

    if yes then how.. plz reply fast..


    Second requirement is

    First two numeric values have to be rounded off and then add them.

    How to do that.. How to round off the values before applying itemSUMfunction.

    If we use number field then we can round off value by using format string.
    but the problem in that is we cannot apply itemsumfunction to number field..

    So plz tell me some other way..

    I will be very very thankful
    Last edited by arunks; 09-02-2008 at 05:00 AM.

  2. #2
    Join Date
    Jul 2006
    Posts
    27

    Smile Round your value in your query

    If you round your value in the query that provides the underlying value in your report, you won't need to round the value in the report.

    Another option is to format the number so there is no decimal portion. You can use '#' or '#,##0' to eliminate the decimal portion from being displayed. However, if you sum the numbers in the column, the sum will include the decimal portion of the number so your total number may not tie out precisely to the sum of the individual (rounded) numbers; which is why I suggested rounding the value in your query instead of trying to manipulate the format of the value in your report.

  3. #3

    Default

    but the problem is that some of my valus i m reading from xml ..

    So plz tell me how to round off them in xquery ..

    in xquery i m just writing
    Code:
     /result-set/*

  4. #4

    Default

    If it's in XQuery, you want to look at using the XPath/XQuery functions. For example: /catalog/book/substring-before(price,".") will return the integer portion of a book price. ceiling(), floor(), and round() also all work, but you'd have to combine that with the formatting hints given earlier to remove the decimal portion.
    Last edited by jternent; 09-02-2008 at 11:09 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.