Search code examples
google-sheetsgoogle-sheets-formula

Count occurrences in specific columns using array formula google sheet


I have database in Google Sheets, Let's say the named sheet is Sheet 1. In Sheet 1, I have data in the range 'Sheet 1'!A:E as pictured below:

enter image description here

In column F, i would like to count the occurrences in columns A, D and E for each row independently and place the count in column F for each respective row.

Below is an example of my expected output based on the sample data above.

enter image description here

Before that, i have created formula using array formula but it not worked. Following my formula in column F:

=ARRAYFORMULA(COUNT(COUNTIF(A2:A<>""; TRUE); COUNTIF(D2:D<>""; TRUE); COUNTIF(E2:E<>""; TRUE)))

Please advise me how I can fix the formula to correct this sheet. Thankyou


Solution

  • You may try this in Cell_F2:

    =byrow(hstack(A2:A;D2:D;E2:E);lambda(Σ;if(counta(Σ)=0;;counta(Σ))))