I have a 3 row by 2 column table
1Q18 hello. testing row one.
2Q18 There are about 7.5b people. That's alot.
3Q18 Last sentence. To be stacking.
I want to split each sentence then have a quarter label with it, out would be
1Q18 hello
1Q18 testing row one
2Q18 There are about 7.5b people
2Q18 That's alot
3Q18 Last sentence
3Q18 To be stacking
I can get one line to work with:
=TRANSPOSE({split(rept(A1&" ",counta(split(B1,".")))," ");split(B1,".")})
which would give me:
1Q18 hello
1Q18 testing row one
I need a formula that will let me go down 100 rows, so I can't manually repeat the formula 3 times and use {} with ;
I've also tried using the
=map(A1:A,B2:B,LAMBDA(x,y,TRANSPOSE({split(rept(x&" ",counta(split(y,".")))," ");split(y,".")})))
but get a
Error Result should be a single column.
try:
=INDEX(QUERY(SPLIT(FLATTEN(LAMBDA(x, IF(x="",,A1:A&""&x))
(SPLIT(B1:B&" ", ". ", ))), ""), "where Col2 is not null", ))
Try below formula-
=QUERY(REDUCE(,B1:B3,LAMBDA(a,x,{a;TRANSPOSE(INDEX(INDEX(A1:A,ROW(x)) & " " & SPLIT(SUBSTITUTE(x,". ",".|"),"|")))})),"offset 1",0)
Here's another formula you can try:
=ARRAYFORMULA(
QUERY(
REDUCE({0,0},
QUERY(A1:A&"❄️"&SPLIT(B1:B,". ",),
"where Col1 <> '#VALUE!'"),
LAMBDA(a,c,
{a;SPLIT(c,"❄️",,)})),
"where Col2 is not null offset 1",))
Related
Okay so i have a this formula:
=ArrayFormula({"Manager:";IF(D5:D="",,IFERROR(VLOOKUP("*"®EXEXTRACT(D5:D,"[a-zA-Z]+")&"*",'Client-Manager'!A:B,2,FALSE),"NO MATCH"))})
It works fine with what i have it doing now but i'm running into a problem now were i need to compare both last and first name and i can't figure out how to do it.
Here is an example sheet:
Sheet im working with
Im comparing in "work-order" sheet column D with and in "manager" sheet column A to then output back on "work-order" sheet column G.
Formula i'm working with resides in "Manager" cell in "work-order" sheet in column G
try:
=ARRAYFORMULA({"Manager:"; IF(D5:D="",,
IFERROR(VLOOKUP("*"®EXEXTRACT(REGEXREPLACE(D5:D, ",", ),
"[a-zA-Z ]+")&"*", 'Client-Manager'!A:B, 2, ),
IFERROR(VLOOKUP("*"®EXEXTRACT(D5:D,
"[a-zA-Z]+")&"*", 'Client-Manager'!A:B, 2, ), "NO MATCH")))})
I have two dates in cells
A1=05.11.2021 18:16
B1=05.11.2021 20:16
I need to find difference in hours between two dates. Result should be (B1-A1)=2 I can't find an answer on the Internet, I ask for help.
use:
=TEXT((DATE(
REGEXEXTRACT(B1, "\d{4}"),
REGEXEXTRACT(B1, "\.(\d+)\."),
REGEXEXTRACT(B1, "^\d+"))+INDEX(SPLIT(B1, " "),,2))-(DATE(
REGEXEXTRACT(A1, "\d{4}"),
REGEXEXTRACT(A1, "\.(\d+)\."),
REGEXEXTRACT(A1, "^\d+"))+INDEX(SPLIT(A1, " "),,2)), "[h]")
arrayformula:
=INDEX(IFNA(TEXT((DATE(
REGEXEXTRACT(B1:B, "\d{4}"),
REGEXEXTRACT(B1:B, "\.(\d+)\."),
REGEXEXTRACT(B1:B, "^\d+"))+INDEX(SPLIT(B1:B, " "),,2))-(DATE(
REGEXEXTRACT(A1:A, "\d{4}"),
REGEXEXTRACT(A1:A, "\.(\d+)\."),
REGEXEXTRACT(A1:A, "^\d+"))+INDEX(SPLIT(A1:A, " "),,2)), "[h]")))
shorter:
=INDEX(IFERROR(1/(1/(TEXT(
REGEXREPLACE(B1:B, "(\d+).(\d+).(\d{4})", "$2/$1/$3")-
REGEXREPLACE(A1:A, "(\d+).(\d+).(\d{4})", "$2/$1/$3"), "[h]")))))
EDIT:
As what #basic mentioned in the above comment, you can format the cell where your output goes or use text with h for hour difference and [h] for the whole duration in hours (got from Cooper's answer). See usage and difference below:
Text:
=text(B1-A1, "h")
or
=text(B1-A1, "[h]")
Update:
Make sure your Date Times uses proper delimiters. / and - are acceptable (e.g. 5/11/2021 18:16:00 or 5-11-2021 18:16:00). (This depends entirely on your locale.)
If you want to show it having . as delimiter, just use a custom Date Time format and use . as its delimiter.
Using custom format:
Actual value vs Display value:
If you don't want to do any changes to the date time and want to have it as text, then replace them using regexreplace before using them in text.
RegexReplace:
=text(REGEXREPLACE(B1, "\.", "/") - REGEXREPLACE(A1, "\.", "/"), "h")
or
=text(REGEXREPLACE(B1, "\.", "/") - REGEXREPLACE(A1, "\.", "/"), "[h]")
I have numbers like the sample below stored in one cell:
First:
[9miles 12lbs weight 1g Raw]
Second:
[1miles 3lbs weight 7g Raw]
Third:
[20miles 6lbs weight 3g Raw]
I'd like to extract the numbers, sum them up () and place them in another cell in the same row. So far I can only manage to extract the first instance of regexp using regexextract formula. Is this even possible?
Desired outcome:
[30miles 21lbs weight 11g Raw]
try:
=INDEX(QUERY(IFERROR(REGEXEXTRACT(SPLIT(
FLATTEN(SPLIT(A1, ":")), " "), "\d+")*1, 0),
"select sum(Col1),sum(Col2),sum(Col4)"), 2)
I have table data in Google Spreadsheet something like this:
Date|Diet
4-Jan-2020|Coffee
4-Jan-2020|Snacks
4-Jan-2020|xyz
4-Jan-2020|Coffee
5-Jan-2020|Snacks
5-Jan-2020|abc
6-Jan-2020|Coffee
6-Jan-2020|Snacks
This table is a list of food items I had on a daily basis. I would like to get the number of times I had coffee on a daily basis. So I would like to get the output like this:
Date | No of times I had Coffee
4-Jan-2020| 2
5-Jan-2020| 0
6-Jan-2020| 1
I used this query to get the output.
=query(A1:B1425,"select A, COUNT(B) where B='Coffee' group by A")
With this query, I get the below output. Do note that I don't get those days when I didn't have coffee
4-Jan-2020| 2
6-Jan-2020| 1
So count for 5-Jan-2020 is missing because there is no string "Coffee" for that day.
How do I get the desired output including the count 0? Thank you.
try:
=ARRAYFORMULA({UNIQUE(FILTER(A1:A, A1:A<>"")),
IFNA(VLOOKUP(UNIQUE(FILTER(A1:A, A1:A<>"")),
QUERY(A1:B,
"select A,count(B)
where B='Coffee'
group by A
label count(B)''"), 2, 0))*1})
or try:
=ARRAYFORMULA(QUERY({A1:B, IF(B1:B="coffee", 1, 0)},
"select Col1,sum(Col3)
where Col1 is not null
group by Col1
label sum(Col3)''"))
you might want to change the counter into an If statement.
Something like "IF(COUNT(B) where B='Coffee' group by A">0,COUNT(B) where B='Coffee' group by A",0).
That will force the counter to have an actual value (0), even when nothing is found
I have the following sheets:
https://docs.google.com/spreadsheets/d/1aC9lsmxVw0pYN_Wjk7gooB0c7CsvmkRsEeCUBEKUIlM/edit?usp=sharing
It should be pretty obvious looking at it. There is a spark-line which becomes green if the the trend is positive. From the data, it makes intuitive sense that the line should be trending up. However, due to the way I wrote the formula, the line is instead trending down and red. How can I reverse the columns being used in the formula?
Note: The data on the right hand side should remain in the same order.
Thanks for any help.
try:
=IFERROR(ARRAYFORMULA(SPARKLINE(
QUERY({B2:B, ROW(B2:B)}, "select Col1 order by Col2 desc"),
{"charttype", "line"; "color", IF(SLOPE(
QUERY({B2:B, ROW(B2:B)}, "select Col1 order by Col2 desc"),
ROW(A2:A)-1)>=0, "lime", "red"); "linewidth", 2})))