• Resolved digiblogger

    (@digiblogger)


    Hi there,

    i have a big Problem.

    Imagine, I want to calculate the total Price of different parts, that have a Price payed, a amount bought and an amount used.

    For example:

    ingredient1 Price: 5.00 Euro
    bought: 100ml
    used: 20ml

    Price / bought * used is the solution for calculating the Price of the amount used. Thats easy.

    But what I one or more ingredients are not bought (so bought is “0”) => results in Division through Zero.

    Is it possible do something like this:

    If incredient1bought = 0 then totalPrice = totalPrice
    Else totalPrice = totalPrice + ingredient1price / ingredient1bought * ingredient1used

    If incredient2bought = 0 then totalPrice = totalPrice
    Else totalPrice = totalPrice + ingredient2price / ingredient2bought * ingredien2used

    If incredient3bought = 0 then totalPrice = totalPrice
    Else totalPrice = totalPrice + ingredient3price / ingredient3bought * ingredien3used

    So totalPrice is updated whenever an “bought” value is not “0”

    Can totalPrice be used as a variable the Price of each used ingredient is added like this?

    I can think of a Workaround creating a Price field for every single ingredient, but this could be a heavy Workaround 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Can variables used in functions?’ is closed to new replies.