If you are starting to get to grips with calculated
fields you have probably started to explore the ability to make your
mathematical equations based on the fields within the entity. But did you know
you can also make calculations across multiple entities?
If you have a lookup field to a second entity, on the entity you are creating the calculated field you will be able to select that field in your formula and then a field from there. It sounds complicated but in reality it is really easy.
In this example we are going to look at the entities order and product. In order we would like a “total price” field, which should be order qty multiplied by “price” in product entity.
Assuming that you have the product as a look up in order it would work very neatly. (and if we don’t have it for some reason create it)
We can now create the “total Price” field, make it calculated and currency
Then click on edit and in the action, you will type your formula. Type in product first as that was the name of the lookup field, then use a full stop straight after and you will then see a list of all the fields in the product entity. Choose the correct one then the * to multiply and choose the quantity field.
Save your calculation, put the field on the entity forms and views and publish and this really is all there is to it. See we said it was simple. Hopefully this can open a few more options to you if you had previously used workflows to populate a field to perform the calculation.