I want to create a field that is a percent value of 2 field: field_so_ho_dan and field_duoc_phu_song
how can i create result = (field_so_ho_dan / field_duoc_phu_song)*100
Srr for my bad english!

Comments

colan’s picture

Category: feature » support
joaomachado’s picture

Were you able to solve this... I too am trying to calculate a percentage from two fields. I get a value, but it is in decimal form and I do not know how to convert it to %.

I know the result just needs to be multiplied by 100 but I do not know how to do that.

I have 0.22 and it should be 21.5.

Here is what I have:
Code:

$entity_field[0]['value'] = 
  $entity_field[0]['value'] = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_accounts_payable_bs'))) /
  $entity_field[0]['value'] = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_customer_deposits_bs')));

Then for Display I have:
$display_output = number_format($entity_field_item['value'] , 2 , '.' , ',');

I have it set as a float!

Joao