Using field type “Formula”

Using this field type you can calculate value by formula.

There are several ways how it can be used:

  1. Simple use values from other fields
  2. Use PHP math function in formula
  3. Use PHP code to calculate value

 

1. Simple use values from other fields
Just for example we have field Profit where Income-Expenses = Profit
Filed Income have ID 116
Field Expenses  have ID 117
Then formula for field Profit will be: [116]-[117]
Numbers in []  are fields ID and they will be replaced by field values.

Value of formula field will be calculated when you add new item only so if you have to change formula you have to update item to update formula field value.

For each materials you can have unlimited Formula fields.

 

2. Use PHP math function in formula
Also in formula you can use any PHP math functions.
For example formula string can be: max([116],[117])
So field will display highest value from fields 116 and 117
See all math functions here http://www.php.net/manual/en/ref.math.php

 

3. Use PHP code to calculate value
PHP code in formula fields have to be inserted in {}
For example:

{
if([116]>0)
{
return [116]/2;
}
else
{
return [117];
}
}

In future we have plan to add formula helper allows you add common formulas.
I think it will be something like Exel has.

This entry was posted in Using Bilt. Bookmark the permalink.

6 Responses to Using field type “Formula”

  1. Anton says:

    Nice feature, tho I’d suggest to comment out line 178 //if(!strstr($formula,’[')) continue;
    otherwise if you don't have any [refs] in your formula it won’t be calculated, which can be essential for php code.

    • kindrosker says:

      this line means you have to use value from other fields in formula filed… do you have examples where we can use formula filed without values from other fields?

  2. Purush says:

    When will the Text-based formulas be available in the tool?

    • kindrosker says:

      100% it will be in next release but I’m not sure when next release will be available… might at the end of this summer.

  3. Matthew Kreh says:

    I’m testing the Bilt 1.1 system to see if it offers the features that I require for a project.

    So far it is working, but I am running into an issue with the Formula field type.

    my materials list has
    Accounts
    – Targets

    Under Accounts, field [94] contains a number.
    Under Targets, field [97] contains a number.

    I wish to subtract one number from the other, but cannot get [94] to work when creating a Target formula field. It is returning the number “94″ instead of the value of the entry in the field referenced by the number 94.

    Can the formula field access it’s parent material’s values like this? Is there a way that I have not learned to use yet?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>