=arrayformula(if(LEN(A:A),if(ROW(A:A)=1,"Outstanding amount Payment", sum(QUERY(daily_fee_collection!A:D,"select D where B="&A:A&"",-1)))))
I am trying to cross-check for payments made in the sheet containing transaction records with the sheet containing the voucher no. against which the purchase was made.
The formula only works if I change A:A in the query string
"select D where B="&A:A&"