Home > Blockchain >  Getting last non-empty column on each row Google Sheets
Getting last non-empty column on each row Google Sheets

Time:06-22

I have this data as output from an ARRAYFORMULA:

A B C
test1 test2 test3
test1
test1 test2
test1 test2 test3

And would like to have this output:

D
test3
test1
test2
test3

How do I get the output above? Having issues with using INDEX and can only pass a single column. If I pass 3 as the column parameter, it will get blank cells on the 2nd and 3rd row. I'm not sure how to proceed after this.

CodePudding user response:

You could create an arrayformula to do this in a single go:

enter image description here

Formula in D1:

=INDEX(REGEXEXTRACT(TRANSPOSE(QUERY(TRANSPOSE("|"&A1:C),,COLUMNS(A1:C))),"([^|]*)[|\s]*$"))

Note: I assumed that "Getting last non-empty column on each row..." meant not all previous column are populated.

CodePudding user response:

In general rules of formula you can user below formula-

=INDEX($A$1:$C$4,ROW(A1),COUNTA(A1:C1))

enter image description here

  • Related