Forum Discussion

Valkyrie6's avatar
Valkyrie6
Copper Contributor
Jan 11, 2024

Help with COUNTIF

 

I have included a picture of what my database looks like for reference.  This database tracks patients hemoglobin results and categorizes them into 3 different categories down at the bottom of the database. 

 

I need the values in the E Column to be counted and sorted into the bottom categories.  Those formulas are as follows: 

=COUNTIFS(E2:E121,">=10",E2:E121,"<=12")

=COUNTIF(E2:E121,">12")

=COUNTIF(E2:E121,"<10")

 

This seems to work fine.  Where I am getting caught up is that if there is also a value in the K Column (meaning we have drawn hemoglobin a second time) I need the formula to not include the result of the first draw (Column E) and instead include the result of the second draw (Column K).  The most recent Hemoglobin draws are the only ones I am interested in counting.  

 

If anyone can point me in the right direction I would be extremely grateful.  Thank you!

 

 

1 Reply

  • Valkyrie6 

    =LET(Hgb,

    IF(K2:K121<>"",K2:K121,E2:E121),

    SUM((Hgb>=10)*(Hgb<=12))

    )

     

    If you work with Office 365 or Excel for the web you can apply this formula. In the first step the formula selects the most recent draw for each row and then it counts the instances >=10 and <=12.

Resources