Is there any method to get the address of the result? - google-sheets

When I use the filter or query to get the result, I want to get the address of the result.
The result is a string type, But column() or row() methods just accept the range on the parameter.
Is there any method to get the address?
Such like the original function address(1,2,4) result (B1)

=CELL("address", INDEX(A2:A, MATCH(
FILTER(A2:A, A2:A="Nancy"),
A2:A, 0), 1))
_______________________________________________________________
=REGEXREPLACE(CELL("address", INDEX(A2:A, MATCH(
FILTER(A2:A, A2:A="Nancy"),
A2:A, 0), 1)), "\$", "")

Related

Query/filter out blank non-specified columns from range

I would like this multiple-criteria query not to show empty columns.
=QUERY({H3:M11}, "select * WHERE
"&TEXTJOIN(" and ", 1,
IF(C3<>"", "Col2 = "&C3&"", ),
IF(B3<>"", "Col3 = '"&B3&"'", )), 1)
Besides, I would also like to know if it's possible to filter it outside a query formula. Currently, I have this formula made by #player0 which is excluding columns with values greater than 0, but I didn't manage to make it work for text.
=FILTER(FILTER(H3:M11, LEN(TRIM(QUERY(IFERROR(1/(1/H4:M11)),,9^9)))>0), {9;
LEN(TRIM(FLATTEN(QUERY(TRANSPOSE(IFERROR(1/(1/H4:M11))),,9^9))))}>0)
Link to the question where this filter formula was found.
Here's the sheet.
Thanks a lot.
try:
=ARRAYFORMULA(QUERY({H3:K11,
FILTER(L3:M11, TRIM(QUERY(L4:M11,,9^9))<>"")},
"where "&TEXTJOIN(" and ", 1,
IF(C3<>"", "Col2 = "&C3&"", ),
IF(B3<>"", "Col3 = '"&B3&"'", )), 1))

Query where Col = range from another sheet

How can I query importrange where Col values = any of the range specified in another sheet?
For example:
=QUERY(IMPORTRANGE("/18UF6ZR19iWulTMHT3lg6mv0NLrghItzW6bRT_p7bzsA/","Data!A2:E"),"select Col4,Col3,Col1,Col2 where Col4 = '"&Helper!A2:A&"'",0)
This workbook has 3 sheets in it:
Data! = Data source
Helper! = Range required for the query to search for
Testing! = Is where I would like the data to return (Testing!A2 has the formula I have tried but it is not working as expected)
https://docs.google.com/spreadsheets/d/18UF6ZR19iWulTMHT3lg6mv0NLrghItzW6bRT_p7bzsA/edit?usp=sharing
I would like it to return data for the range Helper!A2:A but it is currently only returning the data from Helper!A2 I'm not sure what is going wrong as no errors return.
=QUERY(IMPORTRANGE("/18UF6ZR19iWulTMHT3lg6mv0NLrghItzW6bRT_p7bzsA/","Data!A2:E"),"select Col4,Col3,Col1,Col2 where Col4 matches '"&TEXTJOIN("|",TRUE,Helper!A2:A)&"'",0)
use:
=QUERY(IMPORTRANGE("18UF6ZR19iWulTMHT3lg6mv0NLrghItzW6bRT_p7bzsA","Data!A2:E"),
"select Col4,Col3,Col1,Col2
where Col4 matches '"&TEXTJOIN("|", 1, Helper!A2:A)&"'", 0)

Google sheets - Extract numbers with their units of measurment

I want a function that can extract numbers with their units of measurment from a text.
For example in A2 i have:
This box weights 5kg and the other box weights 10 kg.
So i want a function that will return:
5kg 10kg
NOTE: I want the function to work with any unit of measurment, not just "kg".
I am a begginer in google sheets so it would be really helpful if you could provide me with a working function.
You can use this sample custom function that extracts words that starts with a number followed by a character/s.
/**
* #customfunction
*/
function EXTRACTMEASUREMENT(input) {
// match all words which starts with a number
var result = input.match(/\d+[a-zA-Z]+\S*/g)
// combine array into a string separated with spaces
result = result.join(' ');
// Remove special characters(except whitespace) in the string
result = result.replace(/[^\/a-zA-Z0-9\s]/g, '')
return result;
}
Output:
Limitations:
Measurements with spaces between the value and the unit cannot be detected. (See result in cell A5 when space exist in 10 kg.)
Regardless whether the character/s after the number is a valid unit or not, it will be extracted. (See result in cell A5 where 20yy is not a valid measurement unit)
If you want to exempt particular characters not to be removed, you can add them in the braces [^\/a-zA-Z0-9\s] (example / will not be removed).
Note:
This can be improved if you can list valid measurement units that should be supported.
Try
=arrayformula(substitute(transpose(query(flatten(split(
REGEXREPLACE(A1,"([0-9.,/]+[ ]{0,1}[a-z1-3/.\-""]+)","♣♦$1♣")
,"♣")),"select * where Col1 like '♦%' ")),"♦",""))
One more option:
=ArrayFormula(IF(LEN(A:A),
SPLIT(
REGEXREPLACE(
REGEXREPLACE(A:A,"("&
REGEXREPLACE(
REGEXREPLACE(
REGEXREPLACE(A:A,"(\d+[.,/]*\d*(?:\w+|\s\w+)[\""./\-\w+]*)",""),
"\s+\.","|\\."),
"\s+","|")
&")",""),
"(\d)\s","$1")
," ",,1)
,))
try:
=INDEX(SPLIT(FLATTEN(QUERY(TRANSPOSE(IFERROR(SUBSTITUTE(
REGEXEXTRACT(SPLIT(REGEXREPLACE(A1:A, "(\d+.\d+|\d+)", "×$1"), "×"),
TEXTJOIN("|", 1, {"\d+.\d+ ","\d+.\d+","\d+ ","\d+"}&
SORT({"nm";"mm";"cm";"dm";"km";"m";"t";"kg";"dg";"g";"l";"ml";"dl"},
LEN({"nm";"mm";"cm";"dm";"km";"m";"t";"kg";"dg";"g";"l";"ml";"dl"}), 0))),
" ", ))),,9^9)), " "))
update:
all in one cell:
=INDEX(TRIM(FLATTEN(QUERY(TRANSPOSE(IFERROR(SUBSTITUTE(
REGEXEXTRACT(SPLIT(REGEXREPLACE(A1:A, "(\d+.\d+|\d+)", "×$1"), "×"),
TEXTJOIN("|", 1, {"\d+.\d+ ","\d+.\d+","\d+ ","\d+"}&
SORT({"nm";"mm";"cm";"dm";"km";"m";"t";"kg";"dg";"g";"l";"ml";"dl"},
LEN({"nm";"mm";"cm";"dm";"km";"m";"t";"kg";"dg";"g";"l";"ml";"dl"}), 0))),
" ", ))),,9^9))))

More Efficient Way to Avoid Multiple Calculations #4?

Need to know how to put Max Offset function into array formula.
=ArrayFormula(MAX(OFFSET(M42:M46,0,0,5,1)))
This is what I am wanting to change it from.
=MAX(OFFSET(M42,0,0,5,1))
Here is the example in sheets.
https://docs.google.com/spreadsheets/d/180M_qJCE0Bhz5jRX-tAyBc7DIp7HQpCNVGGlrkuguso/edit?usp=sharing
why not:
=ARRAYFORMULA(QUERY(TRANSPOSE(QUERY(TRANSPOSE(ARRAY_CONSTRAIN(SPLIT(TRANSPOSE(QUERY(
TRANSPOSE(ARRAY_CONSTRAIN(IF(IFERROR(SPLIT({"";REPT("♦"&ROW(INDIRECT("A1:A"&COUNTA(M42:M))),
ROW(INDIRECT("A1:A"&COUNTA(M42:M))))}, "♦"))<>"", , TRANSPOSE(SPLIT(REPT(
INDIRECT("M42:M"&COUNTA(M42:M)+41)&" ", COUNTA(M42:M)-5+1), " "))),
COUNTA(M42:M)-5+1, COUNTA(M42:M))), , COUNTA(M42:M))), " "), COUNTA(M42:M)-5+1, 5)),
"select "&TEXTJOIN(",", 1, IF(LEN(TRANSPOSE(SPLIT(REPT("♥♠", COUNTA(M42:M)-5+1), "♥"))),
"max(Col"&ROW(A1:A)&")", ))&"")),
"select Col2"))

What's the proper syntax to query a string in google sheets?

When I use the Query function like this using a number, it returns the correct results:
=QUERY(Sheet2!A1:B12,"select B where A matches '1200'", 0)
But, when I try to match a string, the result is always an empty output:
=QUERY(Sheet2!A1:B12,"select B where A matches 'qwerty'", 0)
This seems ultra-simple, but I can't seem to find an answer anywhere.. What exactly is the correct syntax to match the string? I've included an example of my problem here: sheets_query
I suggest you format ColumnA of Sheet2 as Plain text.
This indeed is simple, instead of matches, you need to use an "=" symbol. So your formula will be =QUERY(Sheet2!A1:B12,"select B where A='qwerty'", 0)
for number it would be:
=QUERY(Sheet2!A1:B12, "select B where A = 1200", 0)
for text, it would be:
=QUERY(Sheet2!A1:B12, "select B where A = 'qwerty'", 0)
for number with external reference:
=QUERY(Sheet2!A1:B12, "select B where A ="&1200, 0)
for text with external reference:
=QUERY(Sheet2!A1:B12, "select B where A = '"&"qwerty"&"'", 0)
for mixed data you can either format it as Plain text or:
=ARRAYFORMULA(QUERY(TO_TEXT(Sheet2!A1:B12), "select Col2 where Col1 = 'qwerty'", 0))

Resources