6 Replies Latest reply on Jun 29, 2017 8:01 PM by avanfosson

Limit number of digits after the ","

Hi,

I am working with Analysis template and i have a problem. I need to get a value with two digits after the ",".

I don't need to round the value. I tried with round(var,2) and format() but it does not work as expected.

Example:

I have: 1,2345

I need: 1,23

Can somebody help me??

Thanks and regards.

• Re: Limit number of digits after the ","

What exactly does 'two digits' mean to you?

The number you say you need is a floating point number having a variable number of digits.How this number is displayed, is controlled by the visualization and/or the PI Points DisplayDigits setting.

If you round to two digits, then the value is rounded to two digits. But beware the syntax: the Round function uses to second argument as: "The size of the unit to round to"

So if i use Round(1.2345,0.01) the output is 1.23

2 of 2 people found this helpful
• Re: Limit number of digits after the ","

Hi,

The "Round" function returns a rounded value. I need to truncate the output to two digits.

Example:

Output

Round(output, 2)

Roundfrac(output, 2)

Thanks and regards.

• Re: Limit number of digits after the ","

Just to clarify because Roger Palmen did provide a good answer.  Both Roundfrac and Round will round a number.  If only 1 argument is provided to Round, then its rounds to an integer.  If 2 arguments are provided to Round, it will round to the specified precision.

Note that Roundfrac(number, 2) actually calls Round(number, 0.01).  They are equivalent statements.

And you are not truncating to 2 digits.  You are indeed rounding with no more than 2 digits.  There is a difference.

1 of 1 people found this helpful
• Re: Limit number of digits after the ","

Hi Pablo,

There are 2 functions to round as well well as another function to truncate.  The Trunc function is takes same inputs as Round, so usage is similar to what Roger Palmen posted.  There is also a Roundfrac(number, digits) function.

Rounding down looks same as Trunc:

Rounding up is different from Trunc:

• Re: Limit number of digits after the ","

Hi,

Thank you for all answers.

I used the "Roundfrac" function and it's works excellent.

Thanks and regards.

• Re: Limit number of digits after the ","

In case anyone is reading this in the future and needs a quick link, here's the Analytics function reference in the Live Library.