How to Track Gain or Loss in Notion
Trading logs only become useful when you can see the dollars you actually made (or lost). In our Notion Investment Tracker tutorial and the Investment Portfolio Tracker template, every sell order is matched back to its original buy so you can surface realized gains instantly. This short walkthrough shows how to recreate that logic inside any Notion database.
1. Define the core properties
Create the following columns in your transactions database:
- Type: Select property with at least two options: Buy and Sell. This tells the formula how to treat the row.
- Linked Buy: Relation property pointing back to the same database. Every Sell entry links to the Buy it is closing.
- Buy Price: Rollup on the Linked Buy relation. Set the rollup to pull the Price property (or whatever field stores your purchase price) using the Show original option.
2. Add the Gain/Loss formula
Create a new Formula property named Gain/Loss and paste the expression below. It calculates profit only on rows marked Sell, leaving Buy rows blank.
if(
prop("Type") == "Sell",
(prop("Price") - toNumber(format(prop("Buy Price")))) * prop("shares"),
""
)

How it works:
prop("Type") == "Sell"
ensures the math runs only for sell orders.prop("Price")
reads the current sale price from the row you're on.toNumber(format(prop("Buy Price")))
converts the rollup (which sometimes returns text) back into a number.- Multiplying by
prop("shares")
returns total profit or loss for that block of shares.
Frequently Asked Questions
Yes. The Gain/Loss formula relies on the relation to retrieve the original buy price. Each sell should link to the buy it closes. If you sell in multiple lots, create separate sell rows and link each one to the appropriate buy.
Set the rollup aggregation to Show original so Notion pulls the first linked value. If you need to average multiple buys, add another relation structure or use average
in the rollup before feeding it into the formula.
After creating the formula, click the property menu and choose the currency format that matches your portfolio. Notion handles the symbol and decimal places automatically.
Yes. Keep a separate formula for Unrealized P&L (using the latest market price) and roll both into summary views. The Investment Portfolio Tracker template demonstrates how to show realized, unrealized, and total returns on one dashboard.