简体   繁体   中英

How to return first not empty cell from importrange values?

my google sheet excel document contain data like this

+---+---+---+---+---+---+
|   | A | B | C | D | E | 
+---+---+---+---+---+---+
| 1 |   | c |   | x |   |
+---+---+---+---+---+---+
| 2 |   | r |   | 4 |   |
+---+---+---+---+---+---+
| 3 |   |   |   | m |   |
+---+---+---+---+---+---+
| 4 |   |   |   |   |   |
+---+---+---+---+---+---+

Column B and D contain data provided by IMPORTRANGE function, which are store in different files.

And i would like to fill column A with first not empty value in row, in other words: desired result must look like this:

+---+---+---+---+---+---+
|   | A | B | C | D | E | 
+---+---+---+---+---+---+
| 1 | c | c |   | x |   |
+---+---+---+---+---+---+
| 2 | r | r |   | 4 |   |
+---+---+---+---+---+---+
| 3 | m |   |   | m |   |
+---+---+---+---+---+---+
| 4 |   |   |   |   |   |
+---+---+---+---+---+---+

I tried ISBLANK function, but apperantly if column is imported then, even if the value is empty, is not blank, so this function dosn't work for my case. Then i tried QUERY function in 2 different variant:

1) =QUERY({B1;D1}; "select Col1 where Col1 is not null limit 1"; 0) but result in this case is wrong when row contain cells with numbers. Result with this query is following:

+---+---+---+---+---+---+
|   | A | B | C | D | E | 
+---+---+---+---+---+---+
| 1 | c | c |   | x |   |
+---+---+---+---+---+---+
| 2 | 4 | r |   | 4 |   |
+---+---+---+---+---+---+
| 3 | m |   |   | m |   |
+---+---+---+---+---+---+
| 4 |   |   |   |   |   |
+---+---+---+---+---+---+

2) =QUERY({B1;D1};"select Col1 where Col1 <> '' limit 1"; 0) / =QUERY({B1;D1};"select Col1 where Col1;= '' limit 1"; 0) and this dosn't work at all, result is always #N/A

Also i would like to avoid using nested IFs and javascript scripts, if possible, as solution with QUERY function suits for my case best due to easy expansion to another columns without any deeper knowladge about programming. Is there any way how to make it simply, just with QUERY , and i am just missing something, or i have to use IFs/javascript?

try:

=ARRAYFORMULA(SUBSTITUTE(INDEX(IFERROR(SPLIT(TRIM(TRANSPOSE(QUERY(
 TRANSPOSE(SUBSTITUTE(B:G, " ", "♦")),,99^99))), " ")),,1), "♦", " "))

0


selective columns:

0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM