Reputation: 103
I want to extract the last non empty value in the column of every row in a spreadsheet I prefer to use arrayformula if thats possible
=transpose(ARRAYFORMULA(COLUMN(B2:ZZZ)))
Here is the spreadheet, that I have tried https://docs.google.com/spreadsheets/d/14iTSYnyKycccVvULCSCyG6cRFNdRoY82YzWSyises2c/copy
Upvotes: 0
Views: 94
Reputation: 396
If you wanted to simply list the last non-empty values for each row that has a value in Column A, you could use the following formula in a separate tab in cell A1, or in the first cell of another column of your choice. I simply added sort
to the formula that @ztiaa came up with.
={"Expected Values";sort(index(iferror(substitute(split(trim(transpose(query(substitute(sort(transpose(Sheet1!B2:I),sequence(columns(Sheet1!B2:I)),)," ","❄️"),,9^9)))," "),"❄️"," ")),,1))}
Upvotes: 1
Reputation: 12823
Another solution (in A2):
=index(iferror(substitute(split(trim(transpose(query(substitute(sort(transpose(B2:I),sequence(columns(B2:I)),)," ","❄️"),,9^9)))," "),"❄️"," ")),,1)
This reverses the range and uses query smush + split + index(,,1) to return the first one. The SUBSTITUTE()s are there to account for possible spaces.
Upvotes: 2
Reputation: 27242
In A2 try
=ArrayFormula(iferror(regexextract(trim(transpose(query(transpose(B2:1000),,rows(B2:1000)))), "[^\s]+$")))
In case there are spaces in the data, try
=ArrayFormula(iferror(substitute(regexextract(trim(transpose(query(transpose(substitute(B2:1000, " ", "~")),,rows(B2:1000)))) , "[^\s]+$"), "~", " ")))
and see if that helps?
Upvotes: 3