Summing and search by text reference

Hello…

I have situation where I want to address cells by text reference and sum iterations based on that reference.
It’s best to be explained with example attached.

In sheet ‘Legend’ I have itemName and value. This may be changed daily, rows inserted and deleted so probably I can’t use it as fixed position.

The trouble lies in sheet “flow”.

I want to accumulate values for each user based on value in sheet ‘Legend’, but wan
t to do that with text references.

So for user 1, I check all rows in ‘flow’ if cell A:B matches with cell A in any row on sheet ‘Legend’ and enter only sum into cell flow.B4

same for user 2, I check all rows in ‘flow’ if cell D:E matches with cell A in any row on sheet ‘Legend’ and enter only sum into cell flow.E4

So user 1 have 2x item 1 + item 2 and item 3
user 2 have 2x item 3 and 4x item 1

Is that possible at all?

testFlowCalc.ods (11.2 KB)

p.s.
I’m novice in libreoffice

https://help.libreoffice.org/7.5/en-US/text/scalc/guide/datapilot.html?DbPAR=CALC#bm_id3150448

Thanks for direction. I think I solved that (at least in example works).