Time difference With 0 Values - google-sheets

Im having a problem in google sheets. I want to sum 2 columns the time that a driver is driving without the stops. So im using this formula to do it:
G7 is 10:20 value and H6 is 10:00.
But I want to do it in all the lines, but when I use the same formula:
I get this value:
Any idea how can I ignore the zero values that are making my database giving me wrong values when in this example the result I want is 00:40. The time driving without the unloads?

use:
=TEXT(SUMPRODUCT(IF(G7:G20="";;G7:G20-H6:H19)); "[h]:mm")

Related

How to use SUMIFS on several lines, using dates

I am trying to sum values using sumifs but I am getting an error. Went throught several website but I guess I don't have a good understanding of how SUMIF works.
Right now I have a sheet with a registry date(C), a price per weeek(G) and a end date(D).
I would want to calculate the earning every week.
So I created another sheet with every week of the year.
=SUMIFS(Clients!G2:G;A5;>=Clients!C2:C;A5;<=Clients!D2:D)
I am not using coma as a separator as my google sheet is not in english.
I am trying to sum the incomes if the date on the second sheet is between the starting date and the end date. But I keep getting errors and I don't really unerstand why.
Thanks
I found an formula which look to be working.
=SUMIFS(Clients!G2:G;Clients!C2:C;"<="&A5;Clients!D2:D;">="&A5)
I guess that it was not working because I was letting A5 to incremente.
Problem solved.
Thanks for your help.
Find out more here on Google's post about =SUMIFS().
Sample usage
SUMIFS(A1:A10, B1:B10, ">20")
SUMIFS(A1:A10, B1:B10, ">20", C1:C10, "<30")
SUMIFS(C1:C100, E1:E100, "Yes")
Syntax
SUMIFS(sum_range, criteria_range1, criterion1, [criteria_range2, criterion2, ...])
sum_range – The range to be summed.
criteria_range1 – The range to be checked against criterion1.
criterion1 – The pattern or test to apply to criteria_range1.
criteria_range2, criterion2, … (OPTIONAL) – Additional ranges and criteria to be checked.

SUMIFS and/or QUERY inside ARRAYFORMULA

Google spreadsheet sample: https://docs.google.com/spreadsheets/d/1MdRjm5QmKY_vaah9c3GrvH6dDOBCQX_zvCubvN0akmk/edit?usp=sharing
Im trying to get the sum of all values for each ID. The values im trying to add up are found in the Source tab while the calculations are done in the Output. My desired values are based on 2 things: ID and Date. The Id is supposed to match and the Date is supposed to be February. I tried first just using a sumif with just matching ID and it worked using this formula: =ARRAYFORMULA(IF(A2:A="",, SUMIF(Source!A:A,A2:A,Source!B:B)))
But when I add the 2nd critera and use a sumifs function, it only outputs for the first id. Here is the sumifs formula I used: =ARRAYFORMULA(SUMIFS(Source!B2:B,Source!A2:A,A2:A,Source!C2:C,">="&DATE(2021,2,1),Source!C2:C,"<="&DATE(2021,2,28)))
I tried using query as some of the answers I found online suggested to use it but it also outputs the first data only, here is the query formula I used =ARRAYFORMULA(QUERY(Source!A2:C,"select sum(B) where A = '"&Output!A2:A&"' and C >= date '"&TEXT(DATEVALUE("2/1/2021"),"yyyy-mm-dd")&"' and C <= date '"&TEXT(DATEVALUE("2/28/2021"),"yyyy-mm-dd")&"' label sum(B) '' "))
I know this is possible by making a temporary query/filter where you only include desired dates and from there I can use SUMIF, but I will be needing to make a monthly total and making 12 of these calculated temporary filters/query would take up a lot of space since we have a lot of data so I want to avoid this option if possible. Is there a better fix to this situation?
Solved by Astrotia - =arrayformula(sumif(I3:I20&month(K3:K20), A2:A6&2, J3:J20))

How to generate a repeating sequence of numbers in google sheet?

So what i need is quite simple, yet somehow i cant get around to find a solution for it.
Basically what i need is for a column, starting from its 2nd row to look list numbers from 1 to 15 and have that sequence repeated all the way to the bottom of the sheet automatically. i was thinking about using arrayformula but couldnt figure out the formula for it.
essentially something like this but it goes all the way down automatically.
Explanation:
You can repeat (REPT) a sequence of numbers from 1 to 15 by using the Sequence formula.
The maximum number of times you want to repeat this sequence will be determined by the total number of rows in your sheet divided by 15.
Solution:
=transpose(split(REPT(concat(JOIN(",",SEQUENCE(1,15)),","),ROUNDDOWN(ROWS(A1:A)/15)),",",true))
Output:
non-REPT solution:
=INDEX(ARRAY_CONSTRAIN(FLATTEN(
SEQUENCE(ROUNDUP(ROWS(A:A)/15), 15)-(
SEQUENCE(ROUNDUP(ROWS(A:A)/15), 1, 0)*15)), ROWS(A:A)-ROW()+1, 1))

Arrayformula to increment value

Basically, I'm trying to increment a value based on the same column with a criteria.
The initial seed is 1 and it should pick up from there.
From the first row that is blank on column C, it should then increment the value by 1. The only exception would be from 12 to 13, that it would then start over from 1.
I've tried using arrayformula with this, but it doesn't work due to interative calculation issues.
Is there any way to make this work?
This should work in B2:
=ARRAYFORMULA(IF(C2:C="",,MOD(COUNTIFS(C2:C,"",ROW(C2:C),"<="&ROW(C2:C)),12)+1))
Does it needs to be an array formula?
You can paste into B3 =if(ISBLANK(C3),B2+1,if(B2=12,1,B2)) and then drag it down the rest of the column.

Getting Corresponding Cell In Google Sheets?

I have a Google sheet for tracking my weight. I have two columns: Date and Weight. While the goal is to have the weight column sorted in descending order, that doesn't always happen in reality...
The data essentially looks like this (weights changed to far lower values, of course):
Date |Weight
04/01/10|195
04/02/10|194
04/03/10|190
04/04/10|198
etc.
Anyway, I have a cell in another spot on the sheet that shows the minimum value from the weight column using this formula
=(Min(B:B))
What I would like to do is display the corresponding date cell for whatever the minimum value from the weight column is. So, with this dataset, I want to show 190 for weight and 04/03/10 for date. Is there any way to get that corresponding cell? I looked through the function reference for Google docs, but can't get anything going. I tried using some of the functions from the Lookup category, but got nowhere. Most want a cell reference, but the min() function returns a value. I think I need to somehow get min() to give me a cell reference, but I don't know how to do that. HLOOKUP() sort of seemed like it might be appropriate, but the docs were a bit spotty, and it didn't do anything but error out the cell.
Of course, I may be barking up the wrong tree entirely.
Thoughts?
I would use the following two formula's:
MIN(B2:B)
FILTER(A2:A;B2:B=minimal value)
If there are more results, they need to be included as well.
See example file I've created: Getting Corresponding Cell In Google Docs Spreadsheet?
Not barking up the wrong tree, actually very close:
=index(A:A,match(min(B:B),B:B,0))
should meet your requirement.
Working inside out: min(B:B) (as you had) returns the lowest weight (ie 190) in ColumnB.
match then finds the position of that value relative to the start of the range in which the value is searched for. So assuming Date is in A1, that returns 4, being the fourth row in ColumnB, where 190 is. The 0 in the formula is to ensure that only the position of an exact match is returned.
Now we know we need the content of the fourth row we can go looking for the value there in ColumnA with index, returning 04/03/2010.
Not all is ideal however. It is possible that a weight of 190 was achieved on separate days. It is the nature of match that where an exact match is required and found the function stops looking for any further instances. Hence as things stand 04/03/2010 will be returned for 190 however often that is the weight for a day after 04/04/2010 - unless other steps are taken, such as to delete/remove/ignore data from 04/03/2010.
You need to change the order of the column as the search column (the weight should be the first in the search array. Then you can use the VLOOKUP formula:
=VLOOKUP(C7,A:B,2,false)
C7 holds the MIN formula that you used: =(Min(A:A)) - note the column order change
one-cell solution to get minimal value with the latest day:
={MIN(B:B), TO_DATE(VLOOKUP(MIN(B:B), SORT({B:B,A:A}, 2, 0), 2, 0))}
to get all minimal values with dates:
=QUERY(A:B, "select B,A where B matches '"&MIN(B:B)&"' order by A desc", 0)

Resources