英文:
IF text appears in another cell
问题
I'm here to help with your Chinese translation. Please provide the specific parts you'd like translated.
英文:
I'm struggling with my IF conditions and would appreciate some help!
I want to know which teachers are available to teach a particular block/period and class.
I have a row for each class, and a column for every teacher, then a formula to say "yes" or "no" if the teacher is available.
The conditions are:
- teachers can only teach 5 classes. after 5, all classes should say "no"
- if a teacher is teaching a class, then no other teachers can teach that class
- if a teacher is teaching in Block A, then they are not available to teach any other Block A classes.
I have used nested IF OR statements for the 3 conditions. The first two seem to be working fine, but I'm struggling with the 3rd. I added some COUNTIFS queries to determine if a teacher is teaching a block, then I used TEXTJOIN so I can see in one cell all the blocks that a teacher is scheduled to teach.
I added an IF statement so that if a block is already listed in the textjoin cell, then the teacher is "no" for that block. It works, but it seems to only look at the last value added to the TEXTJOIN. As soon as I assign another class to the teacher, the previous "no" blocks switch to "yes".
Thank you in advance!
Here's what I've done:
=IF(OR(L$11=$J13,L$2>=5, $K13<>""), "no", "yes")
The IF condition I'm struggling with is:
L$11=$J13 aka Teacher's blocks = the block for this class
To figure out the teachers blocks, I set a formula for all 8 blocks: =IF(countifs($J:$J,"A", $K:$K,L$1)>0,"A","") etc
and then combined them into one text string at L11:
=(TEXTJOIN(",",TRUE, L3:L10))
I think I need a better way of searching the text inside my list of blocks at L11. Alternatively, is there a better way to check if a teacher is already teaching a block?
https://docs.google.com/spreadsheets/d/1kMuzqCTXYGT0Z4X82MhfAPi-nfQScDKqgq0NsaNrEZY/edit#gid=0
答案1
得分: 0
=IF($J14="", "", IF(OR(IFNA(XMATCH($J14, L$2:L$10)), L$2>=5, $K14<>""), "no", "yes"))
=IF($J13="", "", IF(OR(IFNA(XMATCH($J13, L$2:L$10)), L$2>=5, $K13<>""), FALSE, TRUE))
=MAKEARRAY(COUNTA(C13:C), COUNTA(L1:1), LAMBDA(r, c, IF(INDEX(J13:J,r)="", "", IF(OR(IFNA(XMATCH(INDEX(J13:J,r), INDEX(L$2:R$10,,c))), INDEX(L2:2,,c)>=5, INDEX($K13:K,r)<>""), "no", "yes")))
英文:
Here you have an option. Instead of looking into L11 you can do a MATCH inside L3:L10
=IF($J14="","",IF(OR(IFNA(XMATCH($J14,L$2:L$10)),L$2>=5, $K14<>""), "no", "yes"))
(PS: I've also added that first condition so it displays nothing when there's no block assigned)
In case you're interested in the conditional formatting for range J13:R:
=IF($J13="","",IF(OR(IFNA(XMATCH($J13,L$2:L$10)),L$2>=5, $K13<>""), FALSE, TRUE))
And, last but not least, if you want an arrayformula to cover all the range, delete all the formulas in range L13:K, and paste this:
=MAKEARRAY(COUNTA(C13:C),COUNTA(L1:1),LAMBDA(r,c,IF(INDEX(J13:J,r)="","",IF(OR(IFNA(XMATCH(INDEX(J13:J,r),INDEX(L$2:R$10,,c))),INDEX(L2:2,,c)>=5,INDEX($K13:K,r)<>""), "no", "yes"))))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论