#### COUNTIF & FILTER
 - The [COUNTIF][1] function returns a conditional count across a range;  
`=COUNTIF(range, criterion)`  
 
 - The [FILTER][2] function returns a filtered version of the source range, returning only rows or columns that meet the specified conditions.  
`=FILTER(range, condition1, [condition2, ...])`  
 
- By combining [COUNTIF][1] & [FILTER][2] one can [FILTER][2] the data across all days based on a `menu` item, then use [COUNTIF][1] to count occurrences of a `name` in the filtered data.

#### Named Ranges in Formulas
The formula can be adapted for a LAMBDA function 

| name | range | note |
|------|-------|------|
| _mealdata | `F2:O2` | **Daily meals** data entries  |
| _namedata | `F3:O7` | **Daily names** data entries  |
| _namelist | `A2:A7` | **List of names** for filtering data |
| _meallist | `B1:D1` | **List of meals** for filtering data |

#### First Formula
Formula uses named ranges to make the code easier to manage.
```
=COUNTIF(FILTER(_namedata, _mealdata=B$1), $A2)
```
<img src="https://i.sstatic.net/MOiyg.png" width="600" />

#### LAMBDA Function

```
=BYROW(_namelist, LAMBDA(n, MAP(_meallist, LAMBDA(m, COUNTIF(FILTER(_namedata,_mealdata=m),n)))))
```
<img src="https://i.sstatic.net/6m1Y3.png" width="600" />


  [1]: https://support.google.com/docs/answer/3093480
  [2]: https://support.google.com/docs/answer/3093197
  [3]: https://i.sstatic.net/6m1Y3.png