• Resolved kimherbs

    (@kimherbs)


    Hi, I am trying to create a FCC calculator for a formula that calculates the volumes of two (different proof) alcohols that would be needed to achieve a particular ABV. For example, say I have a 75.5% Everclear and 40% brandy and want a final ABV of 60% and a total of 16 ounces of liquid. The formula should calculate the amount of Everclear and brandy needed to create 16 ounces of 60% alcohol.

    The formula looks like this:

    (ABV1 – goalABV) * volume1
    —————————————— = volume2
    goalABV – ABV2


    In the CFF plugin, the formula is input like this:

    ((fieldname2-fieldname8)*fieldname12)/(fieldname8-fieldname7)

    The formula works on its own, but the complication is that there are nested calculations here.

    Meaning the above calculation relies on the answer to a second calculation to determine volume1:

    (goalvolume – volume2) = volume1

    And, of course, volume2 is the solution to the first calculation.

    So the form is set up to collect the known variables: goalABV, ABV1, ABV2 and goalvolume, followed by two calculation fields for volume1 and volume2.

    In practice, though, this is not working. I imagine this is because of the nested calculations – each one relies on a value calculated by the other.

    Is this even possible? Is there a way to do this in a single work flow?

    • This topic was modified 1 year, 3 months ago by kimherbs.
    • This topic was modified 1 year, 3 months ago by kimherbs.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter kimherbs

    (@kimherbs)

    I made two edits to my original question, and I guess saving the multiple edits got my post flagged as spam. Whoops.

    Plugin Author codepeople

    (@codepeople)

    Hello @kimherbs

    You are creating an endless loop. You use volume_2 to calculate volume_1 but need volume_1 to calculate the volume_2. On your page, you describe the process as a trial and error based on your experience. But when you implement an algorithm, there is no trial and error or human experience participating in the process.

    So, you must make some mathematics work first.

    For simplicity, I’ll call the known values as:

    ABV1 => a
    goalABV => b
    ABV2 => c
    goalvolume => d

    And the variables to calculate:

    volume1 => x
    volume2 => y

    x = d – y

    So, I’ll replace it in the initial formula:

    (a-b)*(d-y)
    ———— = y
    (b – c)

    Now all you have to do is clear the “y” variable:

    (a-b)*d
    ———— = y
    (a – c)

    So, the equation to calculate the volume2 would be:

    (fieldname2-fieldname8)*fieldname11/(fieldname2-fieldname7)

    And the equation to calculate the volume1:

    fieldname11-fieldname10

    Now you don’t have a bidirectional dependency or use a trial an error process.

    Best regards.

    Thread Starter kimherbs

    (@kimherbs)

    It works perfectly! Thank you so much for your help ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Troubleshooting a formula with nested calculation values’ is closed to new replies.