You need to sign in to do that

Don't have an account?

Jayne Monat

# Trailhead: Number formula that calculates the volume of a cylinder

I am working on the Trailhead challenge asking me to create a formula field calculating the volume of a cylinder. I am 99% sure my formula is correct but the error message I am getting is asking me to include a "required field" that is not mentioned in the challenge. Here is the prompt:

Your company sells cylindrical hyperbaric chambers. You need a formula field that calculates the volume of a cylinder for you, rounded to the nearest whole number, given its radius and height. Use the existing mathematical formula for the volume of a cylinder, V = πr2h, where r is the radius of the cylinder, h is the height, and π is the constant Pi. Note: Although this formula field might best be created on a custom object, for simplicity, we’ll create this formula on the Opportunity object.Create 2 custom fields of type Number on the Opportunity object: ‘radius’ with a resulting API name of ‘radius__c’ and ‘height’ with a resulting API name of ‘height__c’.

The formula should be named ‘Cylinder Volume’, with the resulting API name ‘Cylinder_Volume__c‘ and should be created on the Opportunity object.

The formula should reference the custom fields ‘radius__c‘ and ‘height__c‘.

The formula should use 3.14159 as an approximation of Pi.

The formula should be named ‘Cylinder Volume’, with the resulting API name ‘Cylinder_Volume__c‘ and should be created on the Opportunity object.

The formula should reference the custom fields ‘radius__c‘ and ‘height__c‘.

The formula should use 3.14159 as an approximation of Pi.

Here is my formula: 3.14159 * (radius__c ^2) * height__c

Here is my error message:

Any help would be appreciated!

Here is my error message:

Any help would be appreciated!

Jeff DouglasJayne,

It looks like you have a required field

alreadyon the Opportunity object that is preventing the test from running successfully. Any way you could remove or make that fieldnotrequired? Or possibly use a brand new developer org as a last resort.Thanks

Jeff Douglas

Trailhead Developer Advocate

## All Answers

Jeff DouglasJayne,

It looks like you have a required field

alreadyon the Opportunity object that is preventing the test from running successfully. Any way you could remove or make that fieldnotrequired? Or possibly use a brand new developer org as a last resort.Thanks

Jeff Douglas

Trailhead Developer Advocate

Jayne MonatAhh, that makes sense, thanks Jeff! Olivier WienerYou also forgot to round your number, ;-) Jayne MonatOliver, do you mean π? That part was fine. The instructions specifically require you to use 3.14159. The formula worked fine when I disabled (thanks Jeff!) a required field I built in a previous Trailhead training. Olivier WienerNo no, the challenge says "rounded to the nearest whole number". In order to achieve that, the correct formula should be:

round(3.14159 * (radius__c ^2) * height__c,0)

;-)

Jayne MonatThere is a field in the formula editor where you can select 0 decimal places, which also does the trick, but thanks for the tip. Olivier WienerI do not fully agree, it will display 3142 as the calculation results in 3141.59, but the actual value is still 3141.59 in SF. The round function will turn that number to 3142.00. My point was that the challenge checking method is probably not verifying if you put that round function in your formula. Maurizio BertiThanks to all! There was a error in the formula (I used the Olivier and Jayne suggestion radius__c ^2 instead EXP(2) ) but to have the right error message I had to delete IsClosed custom field cretaed in a previous exercise. Pratyush Kumar 44HI, Olivier Wiener,

round(3.14159 * (radius__c ^2) * height__c,0) its wrong, please correct it, I tried its not working syntax error.

Amit ChattorajFor those who get this error --- > Answer to the Error

I deleted the Discount Percent (Discount_Percent__c) field and it's related Approval process. Used the Formula ----> Cylinder_Volume = Round(3.14159 * height__c * (radius__c^2),0) And it worked fine. Cheers