Page 1 of 3

Round to nearest even dollar

Posted: Wed Jun 23, 2010 9:17 am
by MikeC
I have a field that needs to be rounded to the nearest even number. For example, if the amount is 6.75 it needs to be rounded to 6. If it's 7.25 it needs to be rounded to 8. Which function (or combination) can do that?

Thanks.

Round to nearest even dollar

Posted: Wed Jun 23, 2010 9:28 am
by Jan
Hello Mike,

Try to use following expression:

Code: Select all

{(int)value == value ? (int)value : (int)value + 1}
Thank you.

Re: Round to nearest even dollar

Posted: Thu Sep 17, 2015 9:43 pm
by jrSD
I need to use this function. However, I am not certain how or where to pit this expression...

Re: Round to nearest even dollar

Posted: Fri Sep 18, 2015 9:39 am
by HighAley
Hello.

You could use this expression in text of text component.

Thank you.

Re: Round to nearest even dollar

Posted: Fri Sep 18, 2015 3:32 pm
by jrSD
So, if my data source is: {Parts.CutPartWidth} how would I apply such?

When I use the following:

{int(Parts.CutPartWidth) == Parts.CutPartWidth ? int(Parts.CutPartWidth) : int(Parts.CutPartWidth + 1);}

I get 'undeclared 'int'' errors. What am I missing here? Any help is GREATLY appreciated.

Re: Round to nearest even dollar

Posted: Fri Sep 18, 2015 7:09 pm
by Jan
Hello,
jrSD wrote:So, if my data source is: {Parts.CutPartWidth} how would I apply such?

When I use the following:

{int(Parts.CutPartWidth) == Parts.CutPartWidth ? int(Parts.CutPartWidth) : int(Parts.CutPartWidth + 1);}

I get 'undeclared 'int'' errors. What am I missing here? Any help is GREATLY appreciated.
Try to use following expression:

Code: Select all

 {(int)Parts.CutPartWidth == Parts.CutPartWidth ? (int)Parts.CutPartWidth : (int)Parts.CutPartWidth + 1}}
p.s. I also correct expression in previous message.

Thank you.

Re: Round to nearest even dollar

Posted: Fri Sep 18, 2015 9:08 pm
by jrSD
Thank you for responding. I am still getting a syntax error though...using:

{(int)Parts.CutPartWidth == Parts.CutPartWidth ? (int)Parts.CutPartWidth : (int)Parts.CutPartWidth + 1}

and also:

{(int)Parts.CutPartWidth == Parts.CutPartWidth ? (int)Parts.CutPartWidth : (int)Parts.CutPartWidth + 1}

Re: Round to nearest even dollar

Posted: Sat Sep 19, 2015 8:13 am
by Jan
Hello,

Second expressions is correct. Can you say which error message you see? Also may be you use VB.NET as script language?

Thank you.

Re: Round to nearest even dollar

Posted: Mon Sep 21, 2015 4:11 pm
by jrSD
The errors i get are as follows:

1. "The error of compilation is found in the 'text' property of the 'Text21' Component: Syntax error."
2. "The error of compilation is found in the 'text' property of the 'Text21' Component: Comma,')', or a valid expression continuation expected.
3. "The error of compilation is found in the 'text' property of the 'Text21' Component: 'int' is not declared. It may be inaccessible due to its protection level.

Thank you very much for any help that could be lent...

Re: Round to nearest even dollar

Posted: Tue Sep 22, 2015 7:52 am
by HighAley
Hello.

You didn't specify what language you use.
Do you use VB.NET script language in the report?

Thank you.