+ Start a Discussion
Nicholas Hale 5Nicholas 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 LoghryJames 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.

All Answers

James LoghryJames 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 5Nicholas 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 LoghryJames 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 BelaRaquel 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 RatnayakeThilina 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 2John Fudali 2
Hale, if you are still stuck. Ithink its order of operations that trips you up. Bracket you exponent.
Jeroen MilewskiJeroen Milewski
How would you do that with the EXP function as explained in this trail?
Natalie Tan 15Natalie 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 KhanRaehan 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.
LorenzoLorenzo
this formula is not working for me! I don't know why!
i have checked the decimal points as well, but is not workingthis is my result, maybe is related to the previous trailhead
Eleanor Lowry 7Eleanor 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.comnbrygt@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 AbdullahAminah 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 ManiDhananjay 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 ManiDhananjay 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 SebastianKarlo 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 KuoPin-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 SmithLaTashia Smith
Did anyone find a resolution to this issue?
Matthew StaffordMatthew 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 94ankur jain 94
@Matthew Stafford thanks you suggestion worked for me.
Josué PeixotoJosué 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:
‘radius’ with a resulting API name of ‘radius__c’
‘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
Advanced Formulas 

See you guys.
Josué Peixoto

 
Andrea GibbAndrea 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 23Neil 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 15Jesica 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.
MKCMKC
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 9RAVITEJA 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 AzurinArmando 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 WurtzJJ 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

Page: https://success.salesforce.com/answers?id=9063A000000l0JWQAY
Pedro RodriguesPedro 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 GeorgievAndrey 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
radius__c and height__c  
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 5subha 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 DenhalterScot 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 HarringtonAlyssa 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 4Tushar Choudhary 4
100 Percent Correct Answer......

ROUND(3.14159 * radius__c * radius__c * height__c,0)

User-added image
Saman AkhgarandoozSaman 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.

Sumit JamadadeSumit Jamadade
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 399Ashish 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 ClementeJerlou Clemente
Thank you so much for your help. Finally, I made it.


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 BezGulzarin Bez
@ Jerlou Clemente thanks you it worked for me.
Reshma Lamani 3Reshma 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 MasalaJojo Masala
Make sure the field is visible to you in the field level security
Trinity ewingTrinity 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