how to calculate a value by rules I have three fields in a content type and want to calulate sum of them in another field.
First, I use Computed Field but it does not work at all.
Then I tried to use conditional field but it is not made for this purpose at all.
So I am trying rules module and make an event: After saving new content(or before) - The condition is: Content is of type [something] - The action: Execute custom PHP code.

And the code is: 

$field_a = field_get_items($entity_type, $entity, 'field_absence');
$field_b = field_get_items($entity_type, $entity, 'field_delay');
$field_c = field_get_items($entity_type, $entity, 'field_vacation');
[node:field-sum] = $field_a[0]['value']+$field_b[0]['value']+$field_c[0]['value'];


But it does not do anything at all. I used the same code in computed field but it has no result. I'm not an expert Drupal programmer. So I need your helps in it. Thanks in advance.
The Math Field module defines a new field type to dynamically calculate values on entity forms. This is an alternative to Computed Field
that does not require the use of PHP Filter.

Note: the above info is an excerpt from its project page.