Forum Discussion
S_L_E
Aug 12, 2025Copper Contributor
Best method to find variances between checkbook deposits and GL deposit transactions
I'm looking for a way to find variances between checkbook deposits and General Ledger deposit transactions. Single checkbook deposits post to the GL as multiple entries (deposits are exported to the...
flexyourdata
Aug 13, 2025Iron Contributor
One idea to consider is a recursive lambda function that processes one check at a time, assigning the check number to as many GL entries as necessary before processing the next check.
The function RECONCILE is defined like this, with comments for clarity:
RECONCILE = LAMBDA(checks, ledger_entries,
LET(
// Add an empty column for the ledger check numbers if necessary
ledger_entries,IF(COLUMNS(ledger_entries)=1,HSTACK(ledger_entries,EXPAND(0,ROWS(ledger_entries),1,0)),ledger_entries),
// get the column with the ledger check numbers
ledger_checks, TAKE(ledger_entries,,-1),
// get the ledger amounts, with already-assigned amounts zeroed out
adj_ledger_amounts, IF(ledger_checks<>0,0,TAKE(ledger_entries,,1)),
// running sum on the adjusted ledger amounts
scanner, SCAN(0, adj_ledger_amounts, SUM),
// drop the processed row
new_checks, DROP(checks,1),
// if the scanner is zero, then the ledger check num is already assigned
// so use it, otherwise if the value from the running sum is
// less than or equal to the deposit of the check being processed, assign
// the new check amount, otherwise don't change the array
new_ledger_checks, IFS(scanner=0,ledger_checks,scanner<=INDEX(checks,1,3),INDEX(checks,1,1),TRUE,ledger_checks),
// replace the ledger-checks column with the newly calculated array
new_ledger_entries, HSTACK(DROP(ledger_entries,,-1),new_ledger_checks),
IF(
// if new_checks is an error, dropping a row has resulted in an empty array
// which means the recursion is finished
ISERROR(AND(new_checks)),
// and just return the new ledger checks
new_ledger_checks,
// otherwise, process the next row
RECONCILE(new_checks,new_ledger_entries)
)
)
);
Assumptions:
- GL entries for check n are all added to the ledger before check n+1
- Checks table has three columns. Headers aren't important, but column 1 should hold a unique identifier for the check and column 3 should hold the check deposit amount
- The initial call to RECONCILE should have a single-column in the second argument
This assigns entire ledger entries to a single check. If the n+1th ledger entry is too large for what remains in the check's deposit amount, it won't be assigned and will be assigned to the next check.
Applying a simple SUMIF of the GL Deposit by Check ID next to the check amount would help find rows which aren't fully accounted for.
=SUMIF(H2#,A2:A3,G2:G9)
- S_L_EAug 16, 2025Copper Contributor
Thank you! I'm eager to try this. I'll post back with results.