How to convert datetime interval to hours? - google-sheets

I have this spreadsheet:
A B C D E
1 08/13/2013 02:10 4
2 08/13/2013 02:19 10 00:09:00 160
In D2, I have this formula : =if(B2="";"";to_date(concatenate(A2;" ";B2))-to_date(concatenate(A1;" ";B1)))
In E2 I have this formula : =if(D2="";"";(C2-C1)/D2)
But E2 outputs the wrong result, 160. I want it to be 40 (=10-4/0.15). 0.15 is the value in D2 converted to hours.
How can I do that?

Do not quite understand what you're trying to calculate, but with the information that explains, the following formula can help:
=IF(D2 = "", "", ROUND((C2-C1)/(D2*24), 0))

Related

How to type static date into formula calculation?

I am trying to create a formula that calculates the number of hours based on the pricing at the time the job was done and the total cost of the job in Google Sheets. Unfortunately, I'm running into a #ERROR when I try to run it and I think it has something to do with how the Dates are typed in and not the logic of the nested IF statements. Any thoughts? Can add more information if needed.
=IF((A2 >= 1/1/21 AND A2 <= 4/13/21), IF(E2 = "Elbow Grease", D2/165, D2/125), IF(E2 = "Elbow Grease", D2/195, D2/155))
A2 would be formatted like 1/1/21
E2 would be a string
D2 would be a numerical value (total cost)
try:
=IF((A2 >= "1/1/21") * (A2 <= "4/13/21"),
IF(E2 = "Elbow Grease", D2/165, D2/125),
IF(E2 = "Elbow Grease", D2/195, D2/155))

How to take all values from a single cell

I have the following data
X f1 f2 f3
1 20 20/5/2 3
2 0 10/5/0 7
3 15 20/2/1 3
4 30 80/0/9 3
I want to make SUM() of all values in f2 column but it gives me an error because of the /.
How can I take each value, separately?
Plus, how to get each relative percentage of each cell in f2? For example, the first cell of f2 would be 74,07 / 18,52 / 7,41 taken from doing (20/27 - 5/27- 2/27)
use:
=INDEX(SUM(IFERROR(SPLIT(F1:F; "/"); 0)*1))
update:
=ARRAYFORMULA(IF(C1:C="";;SUBSTITUTE(FLATTEN(QUERY(TRANSPOSE(ROUND(
IFERROR(SPLIT(C1:C; "/")/MMULT(1*IFERROR(SPLIT(C1:C; "/"));
SEQUENCE(COLUMNS(SPLIT(C1:C; "/")); 1;;)^0))*100; 2));;9^9)); " "; " / ")))

Google sheets Array split function formula

I have this Google sheet:
I am using this formula to split my strings in columns
=ARRAYFORMULA(IFERROR(IF(D2:D=1, SPLIT(A2:A, "+"), SPLIT(C2:C, "+"))))
Molecules ID NAME Vitamin_in_name NAME1 NAME2 NAME3
VITAMIN B1 + VITAMIN B6 + VITAMIN B12 1 VITAMIN B1,B6,B12 1 VITAMIN B1 VITAMIN B6 VITAMIN B12
2 LIDOCAINE + VITAMIN B4,B8,B10 1
3 SALICYLIC ACID + TALC 0 SALICYLIC ACID TALC
I would like to return this sheet. IF the word "vitamin_in_name" = 1 and "molecules" row is empty to re-format the data like in ID2 Column name1, name2, name3. how can i do modify my array formula to do that?
Molecules ID NAME Vitamin_in_name NAME1 NAME2 NAME3 NAME4
VITAMIN B1 + VITAMIN B6 + VITAMIN B12 1 VITAMIN B1,B6,B12 1 VITAMIN B1 VITAMIN B6 VITAMIN B12
2 LIDOCAINE + VITAMIN B4,B8,B10 1 LIDOCAINE VITAMIN B4 VITAMIN B8 VITAMIN B10
3 SALICYLIC ACID + TALC 0 SALICYLIC ACID TALC
Your request is a bit ambiguous, since you didn't specify what should happen if both these conditions are true:
Molecules column is not blank.
Vitamin_in_name is not 1.
I assumed that, in this case, the values should come from column C, and so Vitamin_in_name is not really needed for this.
In any case, I would do the following:
Check if column A is blank with ISBLANK.
If column A is blank then (1) use REGEXREPLACE to replace all , from column C with +VITAMIN, and (2) SPLIT using + as separator.
If column A is not blank, use a simple SPLIT on column A, with + as separator.
The resulting formula could be this:
=ARRAYFORMULA(IFERROR(IF(ISBLANK(A2:A),SPLIT(REGEXREPLACE(C2:C,",","+VITAMIN "),"+"),SPLIT(A2:A,"+"))))

horizontal alternative columns with transpose

Transposing rows in alternate columns
Suppose I have a continuous row
A1 = 1 A2 = 2 A3 = 3 A4 = $
I need to transpose it to
B1 = 1 D1 = 2 F1 = 3 H1 = 4
Is it possible?
=TRANSPOSE({A1; ""; A2; ""; A3; ""; A4})
={A1, "", A2, "", A3, "", A4}
if you are not US localized use: ={A1\ ""\ A2\ ""\ A3\ ""\ A4}
Try:
=if(isodd(column()),"",OFFSET($A1,int(column()-2)/2,))
in B1 and copy across to the right (assuming LTR).

Google sheet -> filtering a query

I created the following sheet:
https://docs.google.com/spreadsheets/d/1AJmzlBlrDZ0mfb_9aSm83fzZxrwYWOxWGxjNhlfqPLA/edit?usp=sharing
I am trying to find a formula to calculate the totals (C7, C8, C9) and wherever it is copied ie C17, C18, C19)
So for C7 I want to sum column D (Duration) wherever:
the Date (col A) is the same as the total row date (that is A7)
The Category (col E) is Internal
Similarly for So for C8 I want to sum column D (Duration) wherever:
the Date (col A) is the same as the total row date (that is A8)
The Category (col E) is External
and
for C9 I want to sum column D (Duration) wherever:
the Date (col A) is the same as the total row date (that is A9)
Has any category
I tried for C7 -
=QUERY({A:E, arrayformula(N(D:D))}, "select sum(Col6) where Col5='Internal' and Col1 = " & A7 & " label sum(Col6) ''",1)
but I get NA ??? any help ?
-
I wouldn't complicate life with a QUERY() here. Instead, just use FILTER().
Total Internal: =SUM(FILTER(D:D, A:A=A7, E:E="Internal"))
Total External: =SUM(FILTER(D:D, A:A=A8, E:E="External"))
Total All: =SUM(FILTER(D:D, A:A=A9))

Resources