roundoff value to decimal 2 place with floor value - xquery

I am looking for help from XQuery experts where I need to round off values of a variable to 2 decimal places along with floor value like below.
say I am getting a variable value like 750.006 - value should be upto 2 decimal place. I am able to achieve that with help of below query.
fn-bea:format-number((xs:decimal($InputValue)),'0.00')
Now the issue is, I would like to have 3rd decimal digit to a floor value like say if
if the value is coming as 750.006 , it should be rounded to 750.01 (upto 2 decimal place)
if value is like 750.004 , it should be 750.00
could someone please help me on this.

You can use fn-bea:decimal-round($value, $scale) to round the value before formatting it:
fn-bea:format-number(fn-bea:decimal-round(xs:decimal($InputValue), 2),'0.00')

Related

Cognos cut off decimal point

In my data set there is a field that is currently a character field and I need to convert it to a numeric one. the problem is not only are there '%' signs hard coded in the data but there are decimal points in there as well and places after the decimal points is not consistent. AKA...
42.01%
8.1%
22%
.05%
I substringed off the % sign but is there a way to just cut the decimal point off and everything after it so then I can just cast it as an integer?
thanks all
Cut % then convert to double. Then apply ceiling function.
What I had to do was put leading 0's on the front of the element because cognos was not reading the entries that started with decimal places. then I had to substring the % off and trim and then cast as a number.

Always display two digits after decimal separator navision

I'm using Microsoft Navision 2009. I'm creating report that includes several number with decimal separator (double/float number in C#).
I'm stuck at the point where I want to display every number with two digits after decimal point.
Ex:
if number is 100, I want to display 100.00
if number is 100.5, I want to display 100.50
if number is 100.55, I want to display 100.55
if number is 100.505; i want to display either 100.51 or 100.50
Thank you in advance;
Language that I'm using is C/AL
Don't be lazy. Read essential manuals. Format function is your best friend in Nav.
strsubstno(text01,format(100.10,0,'<Precision,2:2><Standard Format,0>'))
Third argument of Format is actually the format of result text. <Precision,2:3> means that if first argument is decimal it will have from 2 to 3 (minimum 2 and maximum 3) digits in decimal part. <Standard Format,0> means that the rest of format will be standard.
More here!

How to Remove zeros after decimal points while using Round function in RDLC Reports?

I am Using RDLC Expression for rounding of my data to 4 decimals. but if i use 'Round' function it will show zeros after decimal point if the data has no decimal values.
Ex: If my value is 1 it shows 1.0000.
How to remove zeros?
My Expression: =Round(CDec(Fields!ExchangeRate.Value),4)
I need number without decimal point as whole number, if it has decimal values then it should display with decimal values.
Thanks in Advance.
=Format(CDec(Fields!ExchangeRate.Value),"#.####")
Above Expression Works fine. Thank You.
Simply try this...it works for me.
you can use the Format property of the textbox as
1- right click the textbox
2- click number
3- select Number from the category
4- set Decimal Places to 0
hope it will help you
regards

VBA remove formula and leave original value

I have a spreadsheet called "MTM Lookup", this is downloaded from a specific site, in column D of this spreadsheet are values, but these values have a formula attached to them. The formula rounds these values to 0. The formulas don't round on a specific cell. They look like this =ROUND(35370.6708773751,0) or =ROUND(48368.0427161566,0). I need the values to come through with all the decimals or rounded to 10 decimals but cannot get this to happen, I can remove the formula and leave the value but it is rounded to zero. Please could anyone assist with some simple vba to either remove the =round(,0) or replace the 0 to 10 ie round(x,10).
I don't see any problem in the formula you provided.
When I put
=ROUND(35370.6708773751,0)
to a cell, I correctly see 35371 in the cell.
There are, however, two things in play here.
Formula
Cell Format
For example, when I enter the following value to the cell:
=ROUND(35370.6708773751,10)
I do see 35370.67088 as a result (after rounding to 10 places, cell format rounds it again to 5 decimal places)
I don't know why entering the value without any formula shows you 0, but this leads me to the same suspscion, i. e. that the problem is in the cell format.
You can check it by right clicking on the cell > Format Cells (in office 2010 at least) or programatically, using the following, for example:
sheets("MTM Lookup").range("A:1").numberformat = "0.0000000000"
Hope that it helps.

Weird behaviour on Numeric Stepper decimals

I am making an editor for a field with numbers. I tried a text field, but since it's a Number datatype coming in, it didn't go smoothly -- despite recasting strings as numbers etc.. it kept giving me NaN as the value. So I decided it would be best to go with a numeric stepper.
When I initially loaded it up it would drop all my decimals and only display my numbers as integers. I changed the stepIncrement to 0.1 and now it does show the decimals (a weird requirement imo).. but when I step up it occasionally gives me a value like '17.700000000000003' when I would expect 17.7. All of the numbers in my data have a single decimal place. I know I can write a dataformatter, but it seems like it shouldn't be necessary in this situation.
Is there another way I could deal with this?
You've stumbled upon the compromise of trying to represent decimal numbers in floating point binary formats like IEEE 754. Not all decimal numbers can be exactly represented. You can read up on this issue in great detail here:
http://en.wikipedia.org/wiki/Floating_point#Representable_numbers.2C_conversion_and_rounding
You can use Number.toFixed(fractionDigits:uint) to display to an arbitrary number of decimal places.
You can use the valueFormatFunction which takes the numeric value and formats it to a string. You will need to set explicit widths on your numeric steppers to make they fit though.
in your MXML
<s:NumericStepper valueFormatFunction="stepperFormatter"/>
in your script
protected function stepperFormatter(newValue:Number):String
{
return Math.ceil(newValue).toString()
}

Resources