Exclude empty cells when using SORT() in descending order - google-sheets

Use case
Sort formula against other sheet but exclude empty values after last item. Empty values get sorted at top, creating a whole bunch of blank space, and then data I care about.
=SORT('other sheet'!A1:C36,'other sheet'!D1:D36,FALSE)
A-C is the data I wish to show.
D is the column I wish to sort on.
Problem
The "36" must be manually updated each time I add/remove a row to 'other sheet'.
Possible solution would be:
Get the row number of the last non-empty cell in a column in Google Sheets as [last row].
=SORT('other sheet'!A1:C[last row],'other sheet'!D1:D[last row],FALSE)
What I tried
Lookup("",'other sheet'!A:A)
Result: #N/A
No examples in Help for finding empty cells
Get the last non-empty cell in a column in Google Sheets
Returns value not address. Could find that value in row but not as efficient. Also what if value is found in more than one place?
** Example Speadsheet **
https://docs.google.com/spreadsheets/d/1bqiVe3pBYDJFtrO4EysSKTDq17lzY5r2b8sPV-KnTdI/edit#gid=0

I cannot recreate this in a new spreadsheet. I believe this may be a bug.

If you want to find the last row, you can use the following formula.
=SORT(INDIRECT("'other sheet'!A1:C"&QUERY(TRANSPOSE(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A="")),"select Col1")),INDIRECT("'other sheet'!D1:D"&QUERY(TRANSPOSE(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A="")),"select Col1")),FALSE)
The code in bold is a formula to find the first blank cell in column A in 'other sheet'.
The code in italic return a reference range based on the bolded code.
I hope this help even though it seems to be a very long time since your question.
Edited: I just found out that query can limit rows.
=SORT(INDIRECT("'other sheet'!A1:C"&QUERY(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A=""),"limit 1")),INDIRECT("'other sheet'!D1:D"&QUERY(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A=""),"limit 1")),FALSE)
Edited: Sorry, I didn't read the question carefully. If you want to remove the first blank cell when sort in descending order, you just have to simply add a QUERY function at front, without query for anything.
=QUERY(SORT(INDIRECT("'other sheet'!A1:C"&QUERY(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A=""),"limit 1")),INDIRECT("'other sheet'!D1:D"&QUERY(FILTER(ROW('other sheet'!A:A),'other sheet'!A:A=""),"limit 1")),FALSE),"")

Related

Return Row Data if a Name is Found in a Column

I have a table with names on the left and corresponding work schedules to the right. I've created a separate table with some of those same names and want it to automatically fill in the corresponding work schedule for that person. Seemed simple but I'm very stuck. My level of experience with Google Sheets is what is stopping me from solving this.
Example Tables:
In the attached picture the table on the top is the original (hardcoded) data. The table on the bottom is where I want the schedule data to be automatically produced based on the name on the left. The fields with #N/A and #ERROR! are both failed formulas I tried. #N/A should have returned B7:G7. #ERROR! should have returned B4:G4.
I tried the 'LOOKUP' function with ARRAYFORMULA(INDEX) hoping to have it look up the value in the column and input the work schedule data that corresponds.
=LOOKUP("Clair",A1:A9,ARRAYFORMULA(INDEX(B1:G9)))
yielded an #N/A.
Started trying to use =If(REGEXMATCH(A13:A21,"Clair"),... ...) but the '... ...' shows where my intellectual limits are at the moment. I couldn't finish it because I think it's the wrong formula to use.
Something like this maybe?
Remove everthing in B13:G17, and put this formula in B13
=BYROW(A13:A17,LAMBDA(NAME,XLOOKUP(NAME,A1:A9,B1:G9,"NOT FOUND")))
BYROW() work with an array row by row, the given data A13:A17 has only 1 column, which is the name of staff as lookup value.
Details: https://support.google.com/docs/answer/12570930?hl=en
XLOOKUP() scan an array for a key value (lookup value), and return another array with corresponding row or col index.
Details: https://support.google.com/docs/answer/12405947?hl=en
try:
=INDEX(IFNA(VLOOKUP(A13:A17; A1:G10; SEQUENCE(1; 6; 2); )))

Google sheets match index arrayformula

I have a count using a formula that needs to be stretched (the formula is in cell F9
) https://docs.google.com/spreadsheets/d/1sZM1aAuqkHNONJWagiu3aTw6_vfw515gbiKwhKuQAD4/edit#gid=1464536028
=IF(ISBLANK(E9);;IF(O9=TRUE;INDEX('Тех Лист'!$F$2:$M$2;MATCH(TRUE;Q9:X9;0));IF(P9=TRUE;INDEX('Тех Лист'!$F$3:$M$3;MATCH(TRUE;Q9:X9;0));"Ошибка!")))
I tried to remake it under Arrayformula, but nothing came of it ... later I got the idea to do it through query, but when I add query to the array, the data I need disappears
=INDEX(split(FLATTEN(TRANSPOSE({'Стадник'!$D9:D&"x"&'Стадник'!$Q8:$X8&"x"&'Стадник'!Q9:X&"x"&'Тех Лист'!$F$2:$M$2&"x"&'Тех Лист'!$F$3:$M$3}));"x"))
Please tell me how I can compare the headers, and if the list is TRUE, take the sum from the table
In G9 I entered
=ArrayFormula(if(len(E9:E); vlookup(trim(transpose(query(transpose(if(Q9:X; Q8:Y8;));;50000)))&""; transpose('Тех Лист'!E1:M3)&""; if(O9:O; 2; if(P9:P; 3;));0)+0;))
Note that this solution requires that only one checkbox can be ticked in the range X9:X.
See if that helps ?

Sheet Query formula giving the incorrect output

I have a sheet where the query formula used is very simple.
Here is the test sheet
It just have to display the conetents of the second sheet in the first. Unfortunately, at some point the cell values are merged into single cells.
The example below shows till Apple1 to Apple 10 the data is merged in row 1.
I need a reason for this error and please avoid answering like, delete the row 15 of fruits tab sheet to correct.
Any cause for this is really appreciated.
Sheet2
Sheet1
QUERY has several arguments. If you don't include them, they are assumed to be defaults (with the third argument being to try to make the first row into a header). Try this instead:
=query(Fruits!A3:F,"Select *",0)
or you can leave the middle argument blank in your case:
=query(Fruits!A3:F,,0)

check for duplicate rows (not just a single cell) in google sheets

Hello I would like to check for duplicate rows, not just a cell, in google sheets, i would like to apply this formula in conditional formatting so it would highlight the cell
Here is a sample of what i want to catch
I would like to catch a duplicate row,group,or pair of cells in exact order. Can anybody help me with the formula?
I tried searching and there seems to be no article about it yet, I also tried using countif on both rows and multiply them, but that does not solve it being a pair.
Let's say you have the following data:
https://ibb.co/sFhjN34
First, range select A1:B1001.
Then, paste the following formula in the custom formula bar.
=AND(A1<>"",COUNTIF(ARRAYFORMULA($A:$A&$B:$B),index(ARRAYFORMULA($A:$A&$B:$B),ROW($A1),))>1)
Explaination:
ARRAYFORMULA($A:$A&$B:$B)
This is creating a virtual array which concat two columns A & B.
E.g. juice crackers -> juicecrackers
index(ARRAYFORMULA($A:$A&$B:$B),ROW($A1),)
Since conditional formating will loop through all rows given the starting range you specify earlier (A1:B1001), this part is trying to loop through ROW($A_) such that index(ARRAYFORMULA($A:$A&$B:$B),ROW($A_),) will return the combined word.
COUNTIF(ARRAYFORMULA($A:$A&$B:$B),index(ARRAYFORMULA($A:$A&$B:$B),ROW($A1),))>1)
Count every combined word that it specified in this array ARRAYFORMULA($A:$A&$B:$B)
If it countup more than 1, it means duplicated.
A1<>"" For those blank cells, we ignore it.
Combine the two conditions. AND(A1<>"",COUNTIF(ARRAYFORMULA($A:$A&$B:$B) ....)
It's not quite as perfect as you'd like, but I think this is a start:
=AND($A1=$A2,$B1=$B2)
This doesn't highlight the last row of any matches it finds, but it might be serviceable for what you want (ex. if Row 1 through Row 3 match, it will only highlight Row 1 and Row 2).
Just change the columns to match the two you're working with, and then if you want it to highlight the entire row, change the Apply to range to A1:Z or however many columns you have.

Array formula is misbehaving

I want to add an extra column which takes a value with a VLOOKUP from another sheet and adds the value to each cell in that column if the value's ID matches an id from another column in this spreadsheet.
I have partial success with my formula. It is working for almost all the cells/rows, but it won't populate the last 9 cells(out of 3000 rows) with the desired value.
Here is the formula :
=ARRAYFORMULA(VLOOKUP(G3:INDEX(G3:G,COUNT(G3:G)),'Program IDs'!A$1:B$17,2,0))
I don't understand what is wrong in my formula. Also, the data in the problematic rows is perfectly fine and in the same format as in the other rows.
If my formula seems correct, then I'd like to get suggestions for alternatives to that formula, so I can make it work one way or another.
=ARRAYFORMULA(VLOOKUP(G3:INDEX(G3:G,COUNT(G3:G)+9),'Program IDs'!A$1:B$17,2,0))
There are 9 blank rows somewhere in your 3000 rows. I've made the necessary changes.

Resources