问题
Explanation: I've got 2 tables, one let's say is randomly generated and could contain 5% of the content in the 2nd table or even more. So, the first table let's say has 3 names: Alex, Billy and John, near each name is a fruit: Alex - 2 apples, Billy - 3 pears, John - 5 oranges. Now the 2nd table has many more names, along with Alex, Billy and John. I want to get the numbers and add them to the next table and the type of fruit, also I want it to say that IF Alex has cucumbers he will get -1 from the total amount of fruits and - the numbers of the fruits he already had (meaning that only a group of people could have cucumbers).
In Google sheet, I want it so only the 3rd group (last one) of people from the "Name lists" to be able to have "CT", the rest would get a penalty for it (-1 from total amount and - the numbers from the total number) https://docs.google.com/spreadsheets/d/1n8DF771658l-7lIMu2Jx7YF9ZoHGb3H8UA0eOVd8iaE/edit?usp=sharing
All that is in Project Automation Checker
回答1:
=ARRAYFORMULA(IFERROR(QUERY({E2:G},
"select Col1,sum(Col2),Col3 where Col1 !=''
group by Col1,Col3 label sum(Col2)''", 0)-
N(REGEXMATCH(QUERY(QUERY({E2:G},
"select Col1,sum(Col2),Col3 where Col1 !=''
group by Col1,Col3 label sum(Col2)''", 0),
"select Col1", 0), "[^"&TEXTJOIN("$|^", 1, C2:C)&"$]")), QUERY({E2:G},
"select Col1,sum(Col2),Col3 where Col1 !=''
group by Col1,Col3 label sum(Col2)''", 0)))
spreadsheet demo
来源:https://stackoverflow.com/questions/58167884/search-the-same-text-in-2-tables-then-check-the-cell-next-to-it