We help IT Professionals succeed at work.

formula to round number

PNKJ
PNKJ asked
on
Medium Priority
762 Views
Last Modified: 2012-05-05
Hi
 I am using the following to convert to get rounded numbers in my stored procedure. How can I do the same in crystal report editor and what is the formula for the same. How do you get to the editor

convert(int, round(convert(float,@number)/1000, 0)
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Hi PNKJ,
On the face of it, all you need is a formula field with:

Round(@number/1000,0)

Pete

Author

Commented:
Thanks but where do you write this formula I am trying to click on the column field and format not sure if i am right
CERTIFIED EXPERT
Commented:
You have to create a new Formula Field in the field explorer.

When you have done that you drag the formula field into the report.

Pete

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
A little help with creating a formula

Display the field insertion popup
Click the FORMULA Tab
Click NEW (may have to right click)
Name - MyRoundedNumber
Formula
As Above

Click SAVE
Close the formula editor

Drag the formula onto the report and delete your other field

mlmcc

Author

Commented:
Whenever i try to save it says ) is missing there is error in formula i wen tto feild explorer right click formula fields
Selected new gave the name and the formula editor opened .
I typed Round(@number/1000,0)
when trying to save it gices error ) is missing
CERTIFIED EXPERT

Commented:
What is @number?

Author

Commented:
From data table i have meatproducts, groceries etc these are the colomn names and are returned as such from database for eg datatable_meatproducts

Author

Commented:
I wrote this in formula editor and i get error boolean is required
If {datatable.section} = 1 or Trim({data_table.section_name}) = "yearly report" then
Round({datatable.meatproducts}/1000,0)and
Round({datatable.vegetables}/1000,0)
it is 'and' or 'else you are using in the formula? Replace 'and' with 'else' if you are using 'and' in the formula

Gary
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013
Commented:
If @number is another formula it needs to be in { }

IN your record do you have several numeric values you want rounded?  If so you will need to have a formula for each

For example to get the meat products
If {datatable.section} = 1 or Trim({data_table.section_name}) = "yearly report" then
   Round({datatable.meatproducts}/1000,0)
else
   {datatable.meatproducts}            

for the else part use whatever value you need if it isn't section 1 or the yearly report

mlmcc
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.