Hi Andre Hofer
Based on your description, I understand that you are using a LET + SUMIFS formula to calculate the total quantity of items that match a set of criteria (for example, “CNC” from your Parms sheet). You would like to use the same criteria to calculate the average price as well, instead of relying on a separate AVERAGEIF with a hardcoded condition.
However, AVERAGEIF does not support using a range of criteria (such as a list of keys like "CNC*") in the same way as SUMIFS, so it cannot be applied directly in this scenario.
In this case, you can reuse the same criteria by filtering the matching rows first, and then calculating the average from that filtered result.
=LET(
items,$A$1:$A$300,
price,$E$1:$E$300,
keys,FILTER(Parms!$C$2:$C$3,Parms!$C$2:$C$3<>""),
cond,BYROW(items,LAMBDA(x,SUM(--ISNUMBER(SEARCH(keys,x)))>0)),
IFERROR(AVERAGE(FILTER(price,cond)),0)
)
You may refer to this approach and adjust the ranges or criteria to fit your environment.
If I have misunderstood your scenario or if you need further assistance, please feel free to let me know.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.