Excel Advanced Filter string equal to AND string Not equal to - excel-2010

A column contains strings "abcdef" and "cdef".
A row contains either abcdef or cdef but not both.
What would the Advance filter criteria be for filtering out rows with "cdef" but not "abcdef"

Filter drop menu on cell-> Text filter -> equals "cdef"

Related

How to SPLIT cell content into sets of 50000 characters in new columns Google Sheets

I have 3 columns A, B & C as shown in the image. Column A contains the search key. The second column B contains names and their respective content in the third column C.
I am filtering rows that contain the text in A1 in B:C and concatenating them. The challenge is that each text in the third column is roughly 40k characters. The filter formula works well so the issue is the character limit. This formula =ArrayFormula(query(C1:C,,100000)) which I have in F1 concatenates more than 50000 characters but I am not how to apply it for my case.
Tried to wrap my formula in E1 inside the query function but it wasn't successful. Like so:
=ArrayFormula(query(CLEAN(CONCATENATE(FILTER(C1:C, B1:B=A1))),,100000)).
I also tried to SPLIT the concatenated result into sets of 50000 characters and put the extras in the next columns but wouldn't manage either. The formula I tried in this case is:
=SPLIT(REGEXREPLACE(CLEAN(CONCATENATE(FILTER(C1:C, B1:B=A1))),".{50000}", "$0,"),",")
The link to the spreadsheet
https://docs.google.com/spreadsheets/d/1rhVSQJBGaPQu6y2WbqkO2_UqzyfCc3_76t4AK3PdF7M/edit?usp=sharing
Since cell is limited to 50,000 characters, using CONCATENATE is not possible. Alternative solution is to use Google Apps Script's custom function. The good thing about Apps Script is it can handle millions of string characters.
To create custom function:
Create or open a spreadsheet in Google Sheets.
Select the menu item Tools > Script editor.
Delete any code in the script editor and copy and paste the code below.
At the top, click Save.
To use custom function:
Click the cell where you want to use the function.
Type an equals sign (=) followed by the function name and any input value — for example, =myFunction(A1) — and press Enter.
The cell will momentarily display Loading..., then return the result.
Code:
function myFunction(text) {
var arr = text.flat();
var newStr = arr.join(' ');
var slicedStr = stringChop(newStr, 50000);
return [slicedStr];
}
function stringChop(str, size){
if (str == null) return [];
str = String(str);
size = ~~size;
return size > 0 ? str.match(new RegExp('.{1,' + size + '}', 'g')) : [str];
}
Example:
Based on your sample spreadsheet, there are 4 rows that matches the criteria of the filter and each cell contains 38,976 characters, which is 155,904 characters in total. Dividing it by 50,000 is 3.12. The ceiling of 3.12 is 4 which means we have 4 columns of data.
Usage:
Paste this in cell E1:
=myFunction(FILTER(C1:C, B1:B=A1))
Output:
Reference:
Custom Function

Google Sheets: How do I create an array from a range, adding a column with a constant literal value in every row?

I want to make an array with several columns. The second and subsequent columns are specified as a range pulled from another sheet. The first column is a static constant, that is, every cell in the first column should have the very same literal string value, say 'foo'. I can't find the correct syntax. I'd have thought something like this would work:
={"foo", 'Other Sheet'!C2:F}
but I get "Function ARRAY_ROW parameter 2 has mismatched row size. Expected: 1. Actual: 999." Clearly "foo" needs to be "expanded" to a column with lots of rows. How do I do it, and where are tricks like this documented?
Maybe the answer to this question would give a start: How do I create an array containing a single column, every cell containing "foo", with the number of columns specified by a different range?
Here is an editable sheet illustrating the problem and the desired solution:
https://docs.google.com/spreadsheets/d/17myzKVFN3SDQuubWNdP-dFAbdvdlRbZFkjRpLi2Fas8/edit?usp=sharing
The exact question is this: what formula can I put in cell B9 of Sheet1 to get the current appearance of Sheet1? Notice that I don't know in advance how many rows there are in 'Other Sheet'. It's OK to assume that all rows of Other Sheet have a nonblank value in column C.
You can loop with an arrayformula and assign them to the first column, ending the array with the same size:
={ARRAYFORMULA(if(len('Other Sheet'!C2:C),"foo",)),'Other Sheet'!C2:F}
Side note: that between the {}, if you put a comma ({expr1 , expr2}), the value will be side by side, and if you put a semicolon ({expr1 ; expr2}), the values will be one above the other.
You can use QUERY for that:
=QUERY('Other Sheet'!C2:F, "select 'foo',C,D,E,F where C is not null")
If you want to remove the 'foo' column header, you can use:
=QUERY('Other Sheet'!C2:F, "select 'foo',C,D,E,F where C is not null label 'foo' ''")

DSUM with multiple criteria

I'm trying to get the sum of all items in column F:F when Column J:J = "Channel"and Column K:K = "Country"
=DSUM(Sheet1!$A$1:$K$142,Sheet1!$F$2:$F$142,{{Sheet1!K:K;"Channel"},{Sheet1!L:L;"Country"}})
The above query returns a 0 when it should return a 7.
Try:
=DSUM(Sheet1!$A$1:$L$142, Sheet1!$F$1, {{Sheet1!$K$1; "Channel"}, {Sheet1!$L$1; "Country"}})
Notice changes about the parameters:
Sheet1!$A$1:$L$142 column L:L should be included if you want to use it in your criteria.
Second parameter just needs a column name (Sheet1!$F$1) or its number (6). No need to place the whole range there.
You need to have a two strings range for criteria: first one with the column name, second with the criteria for that column. You set before the whole column K:K and L:L and placed a string to match at the bottom. Only the first tow rows were used, so you criteria was actually like this: kolumn K:K should be like the value in K2 and column L:L like the value in L2 (but this one didn't actually worked as this column was not a part of your table (the 1st parameter)).
Or you can use SUMIFS:
=SUMIFS(Sheet1!$F$2:$F$142, Sheet1!$K$2:$K$142, "Channel", Sheet1!$L$2:$L$142, "Country")
Or if you need to sum the whole column (not just down to 142 row):
=SUMIFS(Sheet1!$F:$F, Sheet1!$K:$K, "Channel", Sheet1!$L:$L, "Country")
Here's a basic proof-of-concept.
Count all vegetables
Answer: 18
Formula: =DSUM(A4:D10,"Qty",{"Category";"Vegetable"})
Count all vegetables at Safeway
Answer: 10
Formula: =DSUM(A4:D10,"Qty",{{"Category";"Vegetable"},{"Store";"Safeway"}})

Google Spreadsheet array filtering

I have a column in google spreadsheet name domains which contains the array of values like ['non work', 'work', 'work', 'non work'], is there a way to find the count within that column which equals to work
Below is the screenshot of what I want to achieve.
In Work Domain Count column values should be respectively 3, 2 and 0
=SUMPRODUCT(REGEXMATCH(TRIM(SPLIT(REGEXREPLACE(A1,"[\[\]\']",""),",")),"^work$"))
REPLACE the non word characters like ',[ with null
SPLIT by the comma ,
Check whether each of the words MATCHes only work
SUM up the TRUEs of such MATCH.

Replace several parts of a string with values from a lookup table

I have a cell with text: "aaa,bbb,ccc,ddd,eee".
I have a lookup table with values corresponding to the different strings. E.g. "aaa"=1, "bbb"=2 etc.
I need to create a single cell with text where the "aaa" etc. have been replaces with their corresponding value.
E.g. the string "aaa,bbb" should create the string "1,2".
Any way to do this?
If your lookup table is in columns A:B and the text you want to replace in cell C1 then try:
=JOIN(",",ArrayFormula(VLOOKUP(SPLIT(C1,","),A:B,2,0)))

Resources