Reputation: 241
I am trying to find a good way to organise the following data. Attached is the screenshot of what the data roughly looks like:
As you can see, the "Order" column has multiple line breaks where each line break indicates one item. I am trying to work out the total cost for each individual, based on the item's price on the bottom right table.
My strategy currently is:
I am currently stuck at step 1. My attempts using FIND
and COUNTA
/COUNTUNIQUE
does not give me the answer I want. Any suggestions?
Upvotes: 0
Views: 39
Reputation: 30281
You may try:
=map(B2:B,lambda(Σ,if(Σ="",,sum(index(ifna(vlookup(split(Σ,", "),E:F,2,)))))))
Upvotes: 1
Reputation: 10277
You can try with this approach:
It splits the value by CHAR(10), which is the breakline, and uses BYCOL to find the value in which the string appears (with REGEXMATCH). Then sums those values
BYROW lets you repeat the process over all of the orders
=BYROW(B2:B,LAMBDA(order,IF(order="","",
SUM(BYCOL(SPLIT(order,CHAR(10),1,1),LAMBDA(each,
FILTER(F2:F,REGEXMATCH(each,E2:E),E2:E<>"")))))))
Upvotes: 2