Auto-increment field based on value of another field How can I have a computed field (field B) that has an auto-incremental number but  based on the value of another field (field A).

For example: I create a node with value "Location X" in field A. Field B should get value X001, I create a second node with value "Location Y" in field A. Field B should get value Y001. I create a third node with, again,  value "Location X" in field A. Field B should get value X002. And so forth
Checkout hook_node_presave() here you can set the values dynamically.
And variable_get() and variable_set() for the increment.

With str_pad() you can add the starting zeros to the increment.

hook_node_presave($node) {
  if ($node-&gt;field_A[LANGUAGE_NONE][0]['value'] == 'Location X') {
    $increment = varibable_get('LocationX_increment', 0);
    $increment++;
    $node-&gt;field_B[LANGUAGE_NONE][0]['value'] = 'X' . str_pad($increment, 3, '0', STR_PAD_LEFT);
    variable_set('LocationX_increment', $increment);
  }
}


You don't need to save the node in this hook, just change the value of the field.