Hi Tyler,
First of all you cannot start your field names with “field_”, ACF will warn you if you try that. So for this example, I simply renamed your field names to a,b, and c (make sure they are all numeric fields).
So if a=100 and b=30, then the formula to use in c is (b / a) * 100
And the answer in this case in field c will be 30.
You can make field c to be Read Only, and you can Append the field with the percentage sign (%). You have to also do that on the front end if you want the % sign to show up…
Good luck.
Nick,
Thanks a ton! I believe this worked.
Do you know how I set field A & B to automatically add commas for things like 10,000?
Sorry for the delay Tyler, I just saw your question:
Let’s say you have a repeater field where you have a calculated sub field (cost), and in the case I want to have a dollar sign in front of the number, and thousands separator.
So I get the value of the subfield (cost) and store it in a variable – in this example $linecost, and then echo that variable, and format it for 2 decimal points. Instead of the 2, if you put 0, then you won’t have decimal points, but you will still get the coma (,) as the thousands separator.
$<?php $linecost = get_sub_field(‘cost’);
echo number_format($linecost,2); ?>
I hope that helps.
-
This reply was modified 5 years, 3 months ago by
nick6352683.
-
This reply was modified 5 years, 3 months ago by
nick6352683.