Copy link to clipboard
Copied
I've read multiple items on this and all seams so simple, but once I try it doesn't work:
I want a profit/loss column. Subtract from Sale Amt from Purchase Amt to give it a positive or negative number.
In the simplified field notation: for profit/loss column
SaleAmt - PurchaseAmt
I get nothing in the field. What am I doing wrong?
Copy link to clipboard
Copied
SFN (Simplified Field Notation) doesn't work with field names that have space in them.
You need to escape space character with backslash like this:
Precio\ Compra - Precio\ Venta
Also, your fields are named:
Precio\ CompraRow1 - Precio\ VentaRow1
Instead of using SFN in every field, you can use this as 'Custom calculation script' use it in only one field (any text field is good) it will calculate for all fields:
for( var i=1; i<=33; i++){
var a = Number(this.getField("Precio CompraRow"+i).valueAsString);
var b = Number(this.getField("Precio VentaRow"+i).valueAsString);
if(a !== 0 && b !== 0)
this.getField("Ganancia PerdidaRow"+i).value = a-b;
else
this.getField("Ganancia PerdidaRow"+i).value = 0;}
Here is your file with script added:
https://drive.google.com/file/d/1R3smEJsCVv48Xp28dNi2W45oASLwvbGb/view?usp=sharing
Copy link to clipboard
Copied
Nesa, thank you so much, but the formula is backwards. I need to show the sale price - the purchase price. That way it properly shows my profit / loss. The current formula is showing the purchase price vs the sale price giving me the opposite answer, when it should be a positive number vs a negative number, unless I actuall had a loss. How can I correct that i the formula?
Copy link to clipboard
Copied
I used the calculation order you had in your file (Precio Compra - Precio Venta).
If the calculation should be opposite, in the script, just change 'a-b' to 'b-a'.