从数据集创建高余额和低余额计算

Creating high and low balance calculations from a dataset

我有一个货币交易清单,我需要从中计算出每种货币余额的高点和低点。我在下面的 Sheet 中创建了一个简单示例:

https://docs.google.com/spreadsheets/d/1fxlfh-WBquyTR7wGKgHE3p2GV1zT9eSdrKmO9FJ3A8E/edit?usp=sharing

这里有六笔交易涉及三种不同的货币。假设交易#1前每种货币的余额为0,我手动计算了三种货币在右边table中的余额高点和低点

我将如何通过公式计算这些平衡高点和低点?

尝试:

=INDEX(QUERY({QUERY(FLATTEN({B2:B, D2:D}), "where Col1 is not null", ), 
 MMULT(--TRANSPOSE(IF((SEQUENCE(1, COUNTA(A2:A)*2)>=SEQUENCE(COUNTA(A2:A)*2))*(
 QUERY(FLATTEN({B2:B, D2:D}), "where Col1 is not null", )=TRANSPOSE(
 QUERY(FLATTEN({B2:B, D2:D}), "where Col1 is not null", ))),
 QUERY(FLATTEN({C2:C, IF(E2:E="",,-E2:E)}), "where Col1 is not null", ), 0)),
 SEQUENCE(COUNTA(A2:A)*2)^0)}, 
 "select Col1,max(Col2),min(Col2) 
  group by Col1 
  label max(Col2)'Balance high',min(Col2)'Balance low'"))