Search code examples
google-sheets

How to count the number of rows that meet a boolean condition?


I have two tables that are compared against each other, row by row, to make a third table. The third table is a schedule meant to be quickly interpreted by humans, and therefore is composed of a bunch of blank cells with conditionally formatted colors: it contains no actual data.

The conditionals that turn the schedule cells various colors are well-developed, but I cannot figure out a scalable way to count the number of times a particular condition returns TRUE (and therefore the number of times a given color appears in a given column).

I thought about using an intermediary table of IFS, but I'd like to avoid that since it would require rebuilding the program from the ground up.

A sanitized version of the data can be found here: https://docs.google.com/spreadsheets/d/1f6g-Tvlq_FeR_ktwqz2EnywB_BOcPj3kenb0jV-3SWw/edit?usp=sharing

The idea is to count the number of timeslots where each task is indicated as green. The rule that turns timeslots green is =let(Σ,filter($C5:$J5,filter(INDIRECT("Quals!$G$6:$N$100"),INDIRECT("Quals!$B6:$B100")=L$3)="Y"),countif(Σ,"Y")=columns(Σ)) In the picture below, the desired output is highlighted in cyan.

enter image description here


Solution

  • You may try:

    =map(L3:Y3,lambda(Λ,sum(byrow(C5:J20,lambda(Δ,let(Σ,filter(Δ,filter(Quals!G6:N100,Quals!B6:B100=Λ)="Y"),--(countif(Σ,"Y")=columns(Σ))))))))
    

    enter image description here