# Need Formula Help - CountIf?

I’m pretty new to Coda formulas so apologies if this is a pretty basic question. But I’m having trouble figuring out the right formula here. Basically, I want a count of each possible value in each row. This is what I’ve tried: CountIf(thisRow, “E”) but it returns the value 1 when I’m trying to get 3, 1, 1, 1. Thank you!

Hello @ambbau

Your approach with CountIf() is not right. This formula requires a list as input, and as far as I know, a row is not considered a list but an object.
So, basically, you want to count the number of columns that contain a specific value, correct? In this case, you need to check each column and add 1 to the result.

Example 1:
CountIf(thisRow.9/4, currentValue = “E”) + CountIf(thisRow.9/5, currentValue = “E”) + CountIf(thisRow.9/6, currentValue = “E”)

Example 2:
If(thisRow.9/4 = “E”, 1, 0) + If(thisRow.9/5 = “E”, 1, 0) + If(thisRow.9/6 = “E”, 1, 0)

Another approach is to combine first all columns in a list and than do the countIf formula.

ListCombine(thisRow.[9/4], thisRow.[9/5], thisRow.[9/6]).CountIf(CurrentValue=“E”)

In all of these, you have to manually add each column. I don’t recall there being a formula to iterate over columns, but perhaps someone else has a different insight on this.

Best Regards,
Arnhold

1 Like

Ah I see, thank you! I’m used to working in a Sheets, so this is new to me.

Would you recommend a different, more automated set up for what I’m trying to achieve?

Hi

First I need to understand what are your needs.
It seems that each column is a date, right? And you want to everyday you can update the status of a row and know how many days that row stayed in specific state.

Is something like that?

Hi @ambbau ,

I took a couple of mins to put together an example of how I would do what you are looking to do (I think).

A separate table to capture the Attendance → Person data helps with the reporting you want to do.

Example doc here: