Google Sheets: How can I sort a range of data but ignore 1 specific row? - sorting

I have a range of data that needs to be sorted (example: B3:D1000) but I want to ignore 1 specific row (example: row B370). Is there a way to write a SORTN function to sort the data while ignoring that one specific row?
Trying to avoid writing a separate FILTER function if possible.

To leave out row 370 and show the rest of the data sorted by column B, use this:
=sort( filter(B3:D, row(B3:D) <> 370) )

Related

Matching (querying?) criteria with IMPORTRANGE

Forgive me if I am not using the correct terminology, I short of crash-coursed myself in Google sheets a few days ago.
Is there a way that I could using IMPORTRANGE to import a data range from spreadsheet 2 into spreadsheet 1, where the range selected from spreadsheet 2 can be matched against criteria in spreadsheet 1 that corresponds to criteria in spreadsheet 2? I have a specific set of data in spreadsheet 1 that, while the same in content, is not in the same order as spreadsheet 2 (which I don't myself maintain) or spreadsheet 3 (which is maintained by someone other than myself or the person that maintains spreadsheet 2), but am being given access to spreadsheet 2 and spreadsheet 3 data that I didn't previously have.
EXAMPLE:
https://docs.google.com/spreadsheets/d/1ByN9Ju8QiiHTfFgow7lDF4VN-zBRqP1gzpAK73ZRBNg/edit?usp=sharing
You work with IMPORTRANGE content the same way as you do with any range within your spreadsheet. Good practice is to use columns with unique content as ID's for searching, filtering, etc.
If you want put the content of somebody's spreadsheet into yours, you can control it.
For example:
In order to get REGISTRATION number from sheet3
Think of VLOOKUP construction:
=VLOOKUP(key,table with key value on the leftmost column;number of column to take value from,false)
You use vlookup formula that takes name in your table as a key (first parameter of formula), then you must rebuild your importrange to have key in leftmost column.
2nd parameter of VLOOKUP will look like this:
{importrange("Sheet3url";"Sheet!Columnwithname"),importrange("Sheet3url";"Sheet!Columnwithregistration")}
This is your temporary table made of 2 importranges.
You want 2nd column of this construction - which is column with registration.
Whole vlookup looks like this:
=VLOOKUP(key,{importrange("Sheet3url";"Sheet!Columnwithname"),importrange("Sheet3url";"Sheet!Columnwithregistration")},2,false)
It's much easier when key is on the left. If you want to extract SEX and DOB you use:
=VLOOKUP(key,importrange("Sheet3url";"Sheet!Columnsfromname to DOB"),2 and then 3,false)
Beware - using multiple importrange makes your sheet slow.
If you have hundreds of rows, you should wrap it around with arrayformula to work with all rows in one go.
Also you can first importrange somebodys table into your sheet on a side and operate inside your sheet.
It's advised when using big datasets and not that many files.

Google Sheets: How can I count the number of rows in a 2 column range where both cells are not empty?

I have a range where I want to count the amount of rows where both cells in this row are not empty. I found a way using a third colum, but I want a cleaner function, preferably one I can contain in one cell.
For example: example
The function should return 1, as there is only one row where both of the cells are not blank.
Thanks for you input!
MSE
This should do what you want
=COUNTIFS(A1:A20,"<>"&"",B1:B20,"<>"&"")

How to filter entries that are not duplicates of entries from others columns in Google Sheets?

I have a column called "Masterlist" which contains values from Lists 1, 2 and 3. It also contains values which are present only in Masterlist.
How can I filter them, like shown at the attached image in Google Sheets?
EDIT: The lists will have more than one entries.
Solution 1
In E2, type in
=filter(A2:A,arrayformula(iserror(match(A2:A,B2:D2,0))))
Check the documentation of filter or match for how to use them. With match, be sure to include the third argument. That is an easy one to forget. arrayformula iterates a formula over a range. The output can be a range, in which case it will print over any un-written cells. When arrayformula interacts with match, it only iterates over the first argument, which is why this solution works.
EDIT: If you have a two-dimensional range to match to, you need to collapse them into a one-dimensional range using the concatenation operators such as
=filter(A2:A,arrayformula(iserror(match(A2:A,{B2:B4;C2:C4;D2:C4},0))))
You can experiment with endings without row indices and let Google Sheets select an ending index for you.
Solution 2
Use the native Filter View feature. Good for the scenarios where you don't need to separately print a list of the unique values in "masterlist".
Go to Data -> Create Filter View
Use the relevant help pages to navigate yourself. I can see a few ways to implement what you desire, including
filter by value on the same column (selecting the actual values manually);
filter by value on a "helper column" where you include a formula in the cells to check whether the content in "masterlist" belongs to the list you want to check against. You can use the match and iserror combo here;
custom formula using a similar formula as above.
If your column A, ie. the "masterlist", is something a user would add to, then Data Validation can be used to good effect in conjunction with Filter View.

sorting in excel error when duplicate data

I am trying formula for sorting of a column in excel. Data is entered in one column and sorted data is output in another one. Please see attached excel file.
As you can see due to same data in second column I am getting rank 2 twice and VLOOKUP cannot find entry named 3 so it is giving error. When all data entered are unique there is no problem but in case of duplicated data I am having problem. What can I do?
Kbv.
Just noticed a third possibility that you miight be looking for. So you want to sort the B items where column A indicates the rank of each item in B:
C2
=VLOOKUP(SMALL($A$2:$A$7,ROW(1:1)), $A$2:$B$7, 2,FALSE)
Old answer:
If you want a custom sort where column A indicates the rank of the resulting item inC , copy the following formula in C2 and fill down.
C2
=SMALL(B$2:B$7,A2)
If you want just to copy the column as sorted "naturally", you dont need any helper column, just type this in the first row and fill down (I used column D in my example image below):
D2:
=SMALL(B$2:B$7,ROW(1:1))

How to create a Range from Table in schematiq

I have a schematiq table containig data I have read from a CSV and parsed into columns. I want to create myself a data link to a range object representing each column so I can then pass those into multiple stats functions.
I've tried =rng.Subset(B5,1,1) on the table which I had hoped would create a range for the first column, but in the views I see I this results in a 1x1 range containing the whole table.
What's the correct syntax?
When you return an array from a Schematiq function, there are two possible forms for that array to take. One is a "range", i.e. a data-linked object that will exist in a single cell regardless of its size, the other is an array function result, which will fill whatever range an array formula has been entered in.
The easiest way to get all the values out of a table as an array is to use tbl.GetValues(), which if you use it without a column argument just returns a rectangular array containing all the data in the table.
However, this is returned as an array function result, so in order to put it into a range you will need to use rng.Create() on that result. The following should work for you in this case:
=rng.Create(tbl.GetValues(B5))
Or, for a specific column:
=rng.Create(tbl.GetValues(B5, "ColumnName"))

Resources