简体   繁体   中英

Query/filter by 3 AND criteria + countif

I'm trying to create a dynamic dashboard for tracking student attendance patterns. When you choose the student from the drop-down in cell C4 in the Student Tracker, the data and charts all change dynamically. The way I've created dynamic charts is by "hiding" queries and other calculations behind the charts and making the text the same color as the background so that they aren't visible. Here's a shared copy of the dashboard with anonymized data: https://docs.google.com/spreadsheets/d/1nyI6h8aiPcJiqPIDWE6AsmCIPt_Vhj0dHdKtmsoqfuk/edit

I'm trying to create a chart that will show monthly patterns for the selected student, looking at the percentage of times they were marked "Present", "Excused absence (E)", etc each month (very similar to the days of the week chart).

This is the formula I tried:

=Countif(Query(ATTDATABASE!$A$2:$M,"select E,G,I,K,M where C='"&$C$4&"' and B >= date '"&TEXT(8/1/2019,"yyyy-MM-dd")&"' and B <= date '"&TEXT(8/31/2019,"yyyy-MM-dd")&"'"),"Present")

It keeps counting 0, even though I know the selected student was marked present in August. Even if I take out the other columns and just leave it as "select E...", it still counts as zero, even though I know the student was marked present on a Monday (column E) in August. I know there's got to be a way to do this, but my Google Sheets chops just aren't quite strong enough yet to figure out the magic combo/syntax.

try:

=COUNTIF(IFERROR(QUERY(ATTDATABASE!$A$2:$M, 
 "select E,G,I,K,M 
  where C='"&$C$4&"' 
  and year(D) = 2019
  and month(D)+1 ="&MONTH(LEFT($G20, 3)&1))), "Present")

0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM