Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
Nicholas Hale 5

Create a Number formula that calculates the volume of a cylinder

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.

Heres the challenge that im stuck on. i have created the 2 custom fields. What im stuck on is where do we create the formula. Do we put it in the custom fields or is there another place u insert it?

thanks if anyone can help

Best Answer chosen by Nicholas Hale 5
James Loghry
I originally got the error when doing the challenge.  Like I mentioned in my post though, it was because my "decimal places" value of the formula was not 0.  Make sure you are returning 0 for the decimal places.

Additionally, try either of the following, as it may be a weird order of operations issue that you could also be running into:
`3.14159 *  (radius__c ^2) *  height__c`

Or

`3.14159 *  radius__c * radius__c *  height__c`

The latter worked for me.

James Loghry
On the Opportunity record, you'll need to create a type of a field called a Formula field.  After you click next when selecting formula, then you'll specify that the formula will return a Number type.  Also, you'll want to make sure that it returns 0 decimal places.

After you click next, then you'll specify the formula ( Pi * r^2 * h), and plug in the appropriate fields and values.

Hope that helps.
Nicholas Hale 5
Challenge Not yet complete... here's what's wrong:
The 'Cylinder_Volume__c' formula field did not return the correct value for a input values of Height of 10 and a Radius of 10. The expected value from the Cylinder_Volume__c formula was 3142.. im getting this error messege. 3.14159 *  radius__c ^2 *  height__c. this is my formula.
James Loghry
I originally got the error when doing the challenge.  Like I mentioned in my post though, it was because my "decimal places" value of the formula was not 0.  Make sure you are returning 0 for the decimal places.

Additionally, try either of the following, as it may be a weird order of operations issue that you could also be running into:
`3.14159 *  (radius__c ^2) *  height__c`

Or

`3.14159 *  radius__c * radius__c *  height__c`

The latter worked for me.
This was selected as the best answer
Raquel Bela
James Loghry was right, i had the same error but i left decimals with 0 and it worked!!!!!!
thank so much from spain!
Thilina Ratnayake
I created Cylinder_Volume__c as Number with 2 decimal places, this is the issue which it didnt validate for me.
Might help for some one who face the same issue, Make sure Cylinder_Volume__c without deceimals
John Fudali 2
Hale, if you are still stuck. Ithink its order of operations that trips you up. Bracket you exponent.
Jeroen Milewski
How would you do that with the EXP function as explained in this trail?
Natalie Tan 15
Thanks, James Loghry.  "On the Opportunity record, you'll need to create a type of a field called a Formula field.  After you click next when selecting formula, then you'll specify that the formula will return a Number type.  Also, you'll want to make sure that it returns 0 decimal places." This did the trick for me.
Raehan Khan
Hi All,

Here's my formula for this trailhead: (3.14159 * radius__c * EXP(2) * height__c)
And this is the error I get, "Challenge Not yet complete... here's what's wrong:
The Opportunity object does not contain the correct formula fields per the requirements. Tip: check for typos in the field names."

I have checked the field names/types for each field and confirm that they are correct. Has anyone seen this issue.
Lorenzo
this formula is not working for me! I don't know why!
i have checked the decimal points as well, but is not working
Eleanor Lowry 7
I have done everything right on this that I can think of--on the Opportunity object, the fields are spelled correctly, the formula is 3.14159 * radius__c * radius__c * height__c (I've tried this using radius__c^2 as well, in brackets), my decimals are set to 0 on all fields--and I'm still getting this error. Is there anywhere else I can look for an incorrect setting?
nbrygt@salesforce.com
I had the same issue and the reason was due to field level security on the custom fields. Enabling read access for all profiles in my org fixed the issue.
Aminah Abdullah
Im trying to complete this challenge and I've read through all the previous posts.

Here's my error: Challenge Not yet complete... here's what's wrong:
The Opportunity object does not contain the correct formula fields per the requirements. Tip: check for typos in the field names.

Here's my formula: Round(3.14159 * Height__c * (Radius__c^2),0)

Any Suggestions?
Dhananjay Mani
@Aminah Abdullah: Try (radius__c^ 2)*height__c*3.14159.  Please mark it best answer because it will work for you to complete this challenge.
Dhananjay Mani
@Eleanor Lowry 7: Try (radius__c^ 2)*height__c*3.14159.  Please mark it best answer because it will work for you to complete this challenge.
Karlo Sebastian
Here's my error:
Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]

What does the discount have to do with the cylinder?

Pin-yu Kuo
I have the same issue as @Karlo Sebastian.
I bet this is a bug of Trailhead.

This is my error message:
Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]
LaTashia Smith
Did anyone find a resolution to this issue?
Matthew Stafford
I had the exact same error and I changed 2 things to fix it. Ensure all 3 fields have length 18 and no decimal places. Then write your formula like this: 3.14159* (radius__c ^2)* height__c
ankur jain 94
@Matthew Stafford thanks you suggestion worked for me.
Josué Peixoto
I originally got the error when doing the challenge, but i did the following:

1 - Create 2 custom fields of type Number on the Opportunity object:
‘height’ with a resulting API name of ‘height__c’.
Boths  with type number

2. Create 1 custom fields of type formula in the Opportunity object:
The formula should be named ‘Cylinder Volume’, with the resulting API name ‘Cylinder_Volume__c‘ and return number with number.

3. In the Simple Fomula insert the code bellow:
(radius__c ^2) * height__c * 3.14159

Assessment Completo!
+500 pontos

See you guys.
Josué Peixoto

Andrea Gibb
I am still getting this error message after trying what Matthew suggested. Any other helpful tips?

Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]
Neil Smith 23
I've tried every formula in this thread and i'm getting the same error message as everyone else. Any help would be appreciated.
Jesica Biecher 15
@Lorenzo, Not sure if you are still having this issue but deactivating the Validation Rule created in the previous module solved it for me.
MKC
I deactivated the validation rule created in previous module and it did not work for me. However i was able to complete this challenge by removing the required check box from the discount_percent__c.

go to: object manager > opportunity > fileds and relationships > discount percent > click on Edit and then remove the "REQUIRED" checkbox under general options.

sakkyo :-)

RAVITEJA C 9
Hi Folks,

Every people doing directly insert an opportunity object . just check if opportunity object is validation rule is applied or not, if applied deactivate that rule and try the challenge. (It shows REQUIRED_FIELD_MISSING, Means your validation rule applied)

This is my error message:
Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]

Raviteja:)
Armando Psalms Azurin
Enable read access for all profiles. Go to Security > Field Accessibility > Opportunity > View by Fields
Select the 3 fields and make sure the Field Access "Visible" and at least "Read Only" are checked for all profiles.
JJ Wurtz
Can not take credit for this so I will post his answer for everyone to see.  Finally was able to complete the module.

Simon Dağcı
Setup-->Object Manager --> Choose (Opportunity)-->Fields-->Edit(Discount_Percent__c]) and uncheck required
This was selected as the best answer

Pedro Rodrigues
1) Setup > Object Manager > Opportunity > Fields & Relationships > New > Number > Radius

2) Setup > Object Manager > Opportunity > Fields & Relationships > New > Number > Height

3) Setup > Object Manager > Opportunity > Fields & Relationships > New > Formula > Cylinder Volume > Cylinder Volume (Number) = 3.14159 * (radius__c ^2) * height__c
Andrey Georgiev
"Create a Number formula that calculates the volume of a cylinder"

I had the formula error, but thing is that the problem is in the unit test under the Trailhead.
It works with simple formulas like this "3.14159 * radius__c * radius__c * height__c"
and it's not necessary to round by function. I workaround the bug in the unit test by
set required properties in
General Options << Required << true //Always require a value in this field in order to save a record

//after this hack ti works doesn't matter is Required field is checked
subha a 5
Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]

Answer: uncheck required for Discount_Percent_c worked for above error

Scot Denhalter
I was having the same problem. I used all of the formulas you guys suggested here. Was still told I didn't have the requisite fields. Then I realized I had performed this challenge in my company's production app, not in my playground. I had forgotten to launch. Launched it. Redid all the instructions. Worked like a charm. Make sure you are in your playground
Alyssa Harrington
@MCK thank you so much that worked for me!!

"go to: object manager > opportunity > fileds and relationships > discount percent > click on Edit and then remove the "REQUIRED" checkbox under general options."
Tushar Choudhary 4

Saman Akhgarandooz

Oh my God!

I cannot believe I was doing this in my production environment the whole time.
Just launch the Playground please and you're good to go.
Note: if everything else is checked by you completely.

Here we facing 2 problems:-
1) Error:-
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]
Solution:-  Setup-->Object Manager --> Choose (Opportunity)-->Fields-->Edit(Discount_Percent__c]) and uncheck required.

2) Error:-
The Opportunity object does not contain the correct formula fields per the requirements. Tip: check for typos in the field names.

Solution:-  Here you Created a new Playground for the Advance section and at the run Time you select the same but you forgot that you were created new objects in your previous Playground that you used for Admin Beginner or Admin Intermediate. So watch your every step while creating objects that you selected the right playground for your action.

Ashish Sharma 399
1. You can re-create the same formula field in other org. It works!!
2. You can use round function here or the below formula also works:
3.14159 * (radius__c ^2) * height__c
Jerlou Clemente

1) Setup > Object Manager > Opportunity > Fields & Relationships > New > Number > Radius

2) Setup > Object Manager > Opportunity > Fields & Relationships > New > Number > Height

3) Setup > Object Manager > Opportunity > Fields & Relationships > New > Formula > Cylinder Volume > Cylinder Volume

Formula:  (radius__c ^2) * height__c * 3.14159

If an error occurs:

= Go to validation rules " CLOSE DATE ALERT"
- deselect active "checked box " under the rule name.

Error:-
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]
Solution:-  Setup-->Object Manager --> Choose (Opportunity)-->Fields-->Edit(Discount_Percent__c]) and uncheck required.

Go to: object manager > opportunity > fields and relationships > discount percent > click on Edit and then remove the "REQUIRED" checkbox under general options."

Gulzarin Bez
@ Jerlou Clemente thanks you it worked for me.
Reshma Lamani 3
Correct Formula-  3.14159* (radius__c^2)* height__c and Put formula return type as 'number' and decimal places as '0'
It worked for me and challege is completed successfully.

Jojo Masala
Make sure the field is visible to you in the field level security
Trinity ewing
Needing help with this challenge as well says "The Opportunity object does not contain the correct formula fields per the requirements. Tip: check for typos in the field names.", I've unchecked the validation rule and do not have a Discount field to uncheck. I've put number type, read-only, and must include values for both objects and I copy and pasted to make sure the spelling was right, not sure what to do? Thank you
Morten Vejsig
My eror was not the formula itself ... it was the simple mistake of creating the Radius and Height fields with CAPITAL letters R and H in front of the field names. Once I had changed those to r and h, the formula I did in the beginning worked as a charm: 3.14 * ( radius__c ^ 2) * height__c
Rajkumar T G
Hi Guys, I Have the Same Problem  It is Showing this Error Message What Should I do Please guide me

"We created an opportunity with radius and height values. We expected the 'Cylinder_Volume__c' field to show the correct cylinder volume, but it didn’t. Make sure that your formula uses the correct calculation for the volume of a cylinder, and that radius x radius is enclosed in parentheses".