So sorry @Bilbo, I completely missed your request! @Travitron - I’ve updated the example here: Community #1059 - Categorizing Transactions - Grist
There are 3 tables; a table of categories, a table of transactions and then a table that categorizes each transaction.
This third table has a reference column to each table, linking transactions to categories.
In the Transactions table, you’ll see the Expense-Tag column. This is a formula column I added to create a nice label to use in the Transaction Categorization table, combining Date, Business and Amount information for the related transaction. This is also a reference column. We use this to link our two widgets so when we select a Transaction, we only see related Categorizations.
When you initially select a transaction that has not been categorized, the Transaction Categorization table will not show anything.
Select a category from the dropdown. Amount will automatically populate with the total amount of the transaction.
This value is editable. So if you need to categorize a portion of this, you can update this value. Then, when you add the next category, it will return the amount minus the already-categorized portion.
This is done via a trigger formula in the Amount column.
The formula here is;
total_categorized = PEEK(SUM(Transaction_Categorization.lookupRecords(Transaction=$Transaction).Amount))
$Transaction.Amount - total_categorized
We use lookupRecords() to find all categorizations for this transaction. We use dot notation to pull the Amount value for each of those records. We use SUM() to summarize all of those amounts. We use PEEK() to avoid the #CircularReference
error.
We set this to apply on new records so it will find the remaining uncategorized Amount when a record is created but then can be edited as needed.
I then added a Fully Categorized formula column. This returns true (or toggled on) if the value in the Amount column for the transaction matches the sum of the Amounts in the categorized table.
SUM(Transaction_Categorization.lookupRecords(Transaction=$id).Amount) == $Amount
If you want to clean up the view, the Expense-Tag column can be hidden from the Transactions table since this is a formula column, working in the background. The Transaction column in the Transaction Categorization table can also be hidden. Linking between the two widgets will continue to work with this hidden.
Please let me know if you have any follow up questions!
Thanks,
Natalie