Apr 02, 2019 05:39 PM
I’m a bit of a newbie and my apologies if this covered elsewhere, I just can’t seem to find the right answer.
I have this formula below to calculate the total weight/value based on calculations below.
I am trying to round up the total to the next 1.5kg because the product comes in tins of 1.5kg.
So I need to calculate:
IF(Fumigant=“FUMITOXIN (ALP)”,ROUNDUP(({H1 vol}Dosage3.0/1000/1.5)*1.5)))
H1 Volume= 5314 * Dosage=1.0 3.0/1000/1.51.5 at the moment it’s equaling 16kg and it should be 16.5
How do i get it to display the .5? Formatting has been set to Decimal 1.00
16.5kg / 1.5kg = 11 TINS
I hope I’m making sense
Apr 02, 2019 09:15 PM
There’s probably a way to make this work using ROUNDUP()
, but having been an English major, I took the low road and did it this way:
IF(
MOD(
({H1 Vol}*{Dosage}*3.0)/1000,
1.5
)>0,
(INT((({H1 Vol}*{Dosage}*3.0)/1000)/1.5)+1)*1.5,
({H1 Vol}*{Dosage}*3.0)/1000
)
Essentially, it checks to see if the calculated amount is evenly divisible by 1.5
. If it is, fine; if not, it takes the integer quotient, adds 1
, and multiplies the result by 1.5
. I tossed a few numbers at it, and it seemed to work — but because of the way Discourse (the software running this forum) interpreted your embedded '*
's, I had to guess at your formula and field names, so you’ll want to double-check my work.
Apr 03, 2019 01:09 AM
Hi @Tyrone_Elliott - the formula you’ve posted above has got a bit mashed in the post formatting so hard to see exactly what you’re using, but a couple of thoughts:
ROUNDUP should always have a precision - precision of 0 rounds up to the next integer value. Because of the formatting, I couldn’t figure out if the precision value is there or not.
Worth trying to calculate the total weight value first (in one column) then do the roundup in another column - sometimes easier to debug and figure out what is going on (you can always combine these down to a single field/column once you have it working correctly).
To answer your question though, ROUNDUP should do the trick. My example below (I’ve simplified the data, but hopefully still valid) illustrates:
So in this case, “Value” is your calculated value; “Exact” is a formula:
Value/1.5
To show the exact number of tins required; “Roundup” is a formula on “Exact”:
ROUNDUP(Exact, 0)
Hope this helps!
JB