RE: Rounding Up to the next whole number
-
Hi there,
I am using the form to create a wallpaper calculator which can only be bought by the metre so need the calculation to round up the result to the next whole metre, for instance 10.3 would need to be 11.
This is what I currently have:
PREC(fieldname8 /134 * fieldname9 /100,0)
How would I need to amend this to show the rounded up result please?
thank you.
-
Hello,
The correct operation to use would be CEIL instead of PREC:
CEIL(fieldname8/134*fieldname9/100)
Best regards.
Thanks for the quick reply, I am trying to calculate wallpaper to round up when displaying the result, the width is 130 and the height is 100, the current formula is CEIL(fieldname8/130*fieldname9/100) but when I type in 100 for the width (fieldname8) and 240 for the height (fieldname9) its displaying 2 metres, when it should be showing 3 metres.
Thanks in advance.
Just to clarify my previous message, the actual width per sheet is 130 and height 100.
so when someone types in 100 as the width they still need to have the minimum width which is 130 x the required height in multiples of 100.thanks.
Hello,
If fieldname8 is replaced by 100, and fieldname9 by 240, the mathematical operation would be:
100/130*240/100 = 1.846153846153846
If you apply a CEIL operation to the previous result (CEIL returns the next integer number) the correct result would be 2 and not 3.
CEIL(1.846153846153846) = 2
The behavior you want implement is not represented by your current equation, for example, if the minimum width allowed is 130, and the minimum height is 100, the equation would be:
CEIL(MAX(fieldname8,130)/130*MAX(fieldname9,100)/100)
Now with this equation and replacing the fields’ names by the corresponding values:
CEIL(MAX(100,130)/130*MAX(240,100)/100)=
CEIL(130/130*240/100)=
CEIL(1*2.40)=
CEIL(2.40)=3Best regards.
Hi again,
I must be getting this wrong somewhere because its still not giving the correct results for me.
Here is the form source code I have pulled from a site which calculates the same as we do, although they also have and adhesive calculator underneath, but we don’t need that, only the wallpaper calculation:<form name=”cp_calculatedfieldsf_pform_1″ id=”cp_calculatedfieldsf_pform_1″ action=”?” method=”post” enctype=”multipart/form-data”>
<!--noptimize--><script>form_structure_1=[[{"form_identifier":"","name":"fieldname2","shortlabel":"","index":0,"ftype":"fnumber","userhelp":"","userhelpTooltip":false,"csslayout":"","title":"Width of wall (CM)","predefined":"eg. 360","predefinedClick":true,"required":true,"size":"small","thousandSeparator":"","decimalSymbol":".","min":"","max":"","dformat":"number","formats":["digits","number"],"fBuild":{}},{"form_identifier":"","name":"fieldname3","shortlabel":"","index":1,"ftype":"fnumber","userhelp":"","userhelpTooltip":false,"csslayout":"","title":"Height of wall (CM)","predefined":"eg. 240","predefinedClick":true,"required":true,"size":"small","thousandSeparator":"","decimalSymbol":".","min":"","max":"","dformat":"number","formats":["digits","number"],"fBuild":{}},{"form_identifier":"","name":"fieldname4","shortlabel":"","index":2,"ftype":"fCalculated","userhelp":"","userhelpTooltip":false,"csslayout":"","title":"Calc 1 width of wall\/130","predefined":"","required":false,"size":"medium","toolbar":"default|mathematical","eq":"fieldname2\/130","optimizeEq":true,"eq_factored":"(fieldname2\/130)","suffix":"","prefix":"","decimalsymbol":".","groupingsymbol":"","dependencies":[{"rule":"","complex":false,"fields":[""]}],"readonly":true,"hidefield":true,"fBuild":{}},{"form_identifier":"","name":"fieldname7","shortlabel":"","index":3,"ftype":"fCalculated","userhelp":"","userhelpTooltip":false,"csslayout":"","title":"calc 2 Round up calc 1","predefined":"","required":false,"size":"medium","toolbar":"default|mathematical","eq":"CEIL(fieldname4)","optimizeEq":true,"eq_factored":"(CEIL((fieldname2\/130)))","suffix":"","prefix":"","decimalsymbol":".","groupingsymbol":"","dependencies":[{"rule":"","complex":false,"fields":[""]}],"readonly":true,"hidefield":true,"fBuild":{}},{"form_identifier":"","name":"fieldname5","shortlabel":"","index":4,"ftype":"fCalculated","userhelp":"","userhelpTooltip":false,"csslayout":"","title":"Calc 3 Height of Wall\/100","predefined":"","required":false,"size":"medium","toolbar":"default|mathematical","eq":"fieldname3\/100","optimizeEq":true,"eq_factored":"(fieldname3\/100)","suffix":"","prefix":"","decimalsymbol":".","groupingsymbol":"","dependencies":[{"rule":"","complex":false,"fields":[""]}],"readonly":true,"hidefield":true,"fBuild":{}},{"form_identifier":"","name":"fieldname6","shortlabel":"","index":5,"ftype":"fCalculated","userhelp":"","userhelpTooltip":false,"csslayout":"","title":"Calc 4 height*no. of drops","predefined":"","required":false,"size":"medium","toolbar":"default|mathematical","eq":"fieldname5*fieldname7","optimizeEq":true,"eq_factored":"((fieldname3\/100)*(CEIL((fieldname2\/130))))","suffix":"","prefix":"","decimalsymbol":".","groupingsymbol":"","dependencies":[{"rule":"","complex":false,"fields":[""]}],"readonly":true,"hidefield":true,"fBuild":{}},{"form_identifier":"","name":"fieldname8","shortlabel":"","index":6,"ftype":"fCalculated","userhelp":"","userhelpTooltip":false,"csslayout":"","title":"Calc 5 10% waste","predefined":"","required":false,"size":"medium","toolbar":"default|mathematical","eq":"fieldname7*0.1","optimizeEq":true,"eq_factored":"((CEIL((fieldname2\/130)))*0.1)","suffix":"","prefix":"","decimalsymbol":".","groupingsymbol":"","dependencies":[{"rule":"","complex":false,"fields":[""]}],"readonly":true,"hidefield":true,"fBuild":{}},{"form_identifier":"","name":"fieldname9","shortlabel":"","index":7,"ftype":"fCalculated","userhelp":"","userhelpTooltip":false,"csslayout":"","title":"Calc 6 Required","predefined":"","required":false,"size":"medium","toolbar":"default|mathematical","eq":"fieldname6+fieldname8","optimizeEq":true,"eq_factored":"(((fieldname3\/100)*(CEIL((fieldname2\/130))))+((CEIL((fieldname2\/130)))*0.1))","suffix":"","prefix":"","decimalsymbol":".","groupingsymbol":"","dependencies":[{"rule":"","complex":false,"fields":[""]}],"readonly":true,"hidefield":true,"fBuild":{}},{"form_identifier":"","name":"fieldname10","shortlabel":"","index":8,"ftype":"fSectionBreak","userhelp":"","userhelpTooltip":false,"csslayout":"","title":"","fBuild":{}},{"form_identifier":"","name":"fieldname1","shortlabel":"","index":9,"ftype":"fCalculated","userhelp":"","userhelpTooltip":false,"csslayout":"","title":"Metres required:","predefined":"0","required":false,"size":"small","toolbar":"default|mathematical","eq":"CEIL(fieldname9)","optimizeEq":true,"eq_factored":"(CEIL((((fieldname3\/100)*(CEIL((fieldname2\/130))))+((CEIL((fieldname2\/130)))*0.1))))","suffix":" Metre\/s","prefix":"","decimalsymbol":".","groupingsymbol":"","dependencies":[{"rule":"","complex":false,"fields":[""]}],"readonly":true,"hidefield":false,"fBuild":{}},{"form_identifier":"","name":"fieldname12","shortlabel":"","index":10,"ftype":"fCalculated","userhelp":"","userhelpTooltip":false,"csslayout":"","title":"Calc 7 Adhesive Required","predefined":"","required":false,"size":"medium","toolbar":"default|mathematical","eq":"fieldname1\/16","optimizeEq":true,"eq_factored":"((CEIL((((fieldname3\/100)*(CEIL((fieldname2\/130))))+((CEIL((fieldname2\/130)))*0.1))))\/16)","suffix":"","prefix":"","decimalsymbol":".","groupingsymbol":"","dependencies":[{"rule":"","complex":false,"fields":[""]}],"readonly":true,"hidefield":true,"fBuild":{}},{"form_identifier":"","name":"fieldname11","shortlabel":"","index":11,"ftype":"fCalculated","userhelp":"","userhelpTooltip":false,"csslayout":"","title":"Adhesive Required:","predefined":"0","required":false,"size":"small","toolbar":"default|mathematical","eq":"CEIL(fieldname12)","optimizeEq":true,"eq_factored":"(CEIL(((CEIL((((fieldname3\/100)*(CEIL((fieldname2\/130))))+((CEIL((fieldname2\/130)))*0.1))))\/16)))","suffix":" Tub\/s","prefix":"","decimalsymbol":".","groupingsymbol":"","dependencies":[{"rule":"","complex":false,"fields":[""]}],"readonly":true,"hidefield":false,"fBuild":{},"predefinedClick":false}],{"0":{"title":"","description":"","formlayout":"right_aligned","formtemplate":"cp_cff_elegant"},"formid":"cp_calculatedfieldsf_pform_1"}];</script><!--/noptimize-->
<div id=”fbuilder”>
<div id=”fbuilder_1″>
<div id=”formheader_1″></div>
<div id=”fieldlist_1″></div>
</div>
</div>
<div class=”clearer”></div>
</form>Is it possible to pull the information needed there, and if so could you tell me exactly which equations I need to put in which boxes please, I’m sorry to be a pain, just want to get this working.
Am I correct in understanding the only thing that needs to be set in the width of wall and height of wall fields are the field labels? and the actual calculation (whatever that might amount to) needs to go onto the ‘metres required’ field?Kind Regards
Hello,
I’m sorry, but the support service does not cover the implementation of the users forms or formulas. If you need additional help implementing your project, I can offer you a custom coding service through my private website:
https://cff.dwbooster.com/customization
However, I can give you some tips:
If the minimum width allowed is 130, you should edit the equation associated to the fieldname4 as follows:
MAX(fieldname2,130)/130
and something similar occurs with the equation associated to the fieldname5 field if the minimum height allowed is 100:
MAX(fieldname3,100)/100
Best regards.
- The topic ‘RE: Rounding Up to the next whole number’ is closed to new replies.