Sheets record time vs PB time delta - google-sheets

I'm making a spreadsheet to track and compare PB times in a racing game to records in different regions. Trying to figure a way to show a + / - time differential comparing my time to the selected region's record time.
I found a way to make this work in Excel (using the SIGN formula and an if statement to combine the + or - to the calculated difference, required 2 extra columns which had to be hidden which wasnt ideal), but sheets doesn't agree with the format of my data (Tried with it being number, text, time and a custom mm:ss.000 format too).
Is there a way to do this in sheets and preferably a way that just requires the single cell to figure it out?
Thanks!
*Looking to have the time differences shown in the J column, comparing my PB time to the times adjacent times

Here's one solution, but you need to adjust your time format from mm:ss.000 to HH:mm:ss.000 to be able to subtract your time values. Then use TEXT() to convert the results to your desired format
Sample Formula: (Format: +/- s.000)
=if($B$1-$B2>0,"+ ","- ")&text(abs($B$1-$B2),"s.000")
Sample Formula: (Format: +/- mm:ss.000)
=if($B$1-$B2>0,"+ ","- ")&text(abs($B$1-$B2),"mm:ss.000")
Output:

Related

Trying to only SUM values in one column based on if the adjacent cells in another column contain a formula

So I'm creating a Google Sheets doc that contains my hours and overtime for an hourly position I have, and how much overtime I'll need to make the amount of money I need to make to survive.
In addition to this I am also trying to track my hours so I can track the actual amount of money I'm making.
So I have a projected clock out time in Column B that uses a formula to tell me what time I need to ideally clock out at based on how many hours I need and what time I clocked in at. When I clock out, I enter the actual time I clocked out at.
In Column C I have the total amount of hours I worked that day, formatted in duration based on the difference between the value in Column A and Column B. If I haven't entered in a value in Column B, it shows me the ideal amount of hours I need that day.
I want to calculate my actual hours worked per week as I'm working that week, so I need to ONLY sum the values in Column C if the adjacent value in Column B is NOT a formula. So I need it to sum the values in column C if I've entered the actual time that I clocked out at in column B.
I've looked up this question and tried multiple solutions I've found here, even tried troubleshooting with ChatGPT, but most are just trying to sum the range that contains the values/formula, and not summing a different column based on if another column has formulas or not.
There seems to be a lot of posts that come super close but don't seem to work for how I need this to work.
Edit: Here is the example sheet.
So F3:F6 are values that have been manually entered, while F:7 has been calculated by a formula.
I need H9 to sum the values of H3:H7, but only the values adjacent to the times in the F column that have been manually entered. In this example, I need it to sum H3:H6 and ignore H7 until I enter a time and remove the formula in F7.
try:
=SUMPRODUCT(MAP(F3:F7,LAMBDA(z,IFNA(FORMULATEXT(z),1))),H3:H7)
You may filter and check if there is a formula with FORMULATEXT. If there isn't it will throw a #N/A error. Then with ISNA it will keep the values in which its adjacents did'nt have a formula:
=SUM(FILTER(C:C,BYROW(B:B,LAMBDA(b,ISNA(FORMULATEXT(o))))))

Google sheet time difference calculation

I want to calculate Total of time difference by creating a funtion in Google Sheet
The format of time Difference is : text(C7-B7,"hh:mm:ss")
Google Sheet
How should I calculate the total of time difference.If I use Add ons it works well but I want to make a custom function which calculates the total of all the difference hours as soon as stop is clicked
If you need to sum, stay away from the text-conversion implied in the formula you shared. Instead try something like:
=MOD(C7-B7, 1)
and set the formatting of the column to 'duration' (if needed).
Then you should be able to sum the differences and obtain the total.
Hope that helps?

Google Spreadsheets Repeat Function Nth Times & Sum Results

I have the following function
=IF(RAND()<0.25,1,0)
RAND() returns any value between 0 to 1 in decimal format and the idea is that an item has a 25% chance of getting a 1. If it was less than 0.25 the rand() then its a hit and gets a 1 otherwise a 0. Now lets say I need to do this 100 times and add up the sum of all the '1's that were created, which in this case will average to around 25 for 25%. How do I do this in Google Spreadsheets?
Basically looking for a way to repeat a function n'th amount of times and sum the results.
I have looked around everywhere (youtube, google forums) and have not found any solutions.
I may as well put this as an answer because it tries to address the broader question of whether you can repeat a function (say) 100 times. The answer is, yes if the function is compatible with an array formula. Rand can't be used in this way because it doesn't take any arguments (neither do some other functions like countifs for some reason). But you could get round it by using Randbetween instead and providing it with 100 array elements. These are multiplied by zero so don't actually affect the answer, but Google Sheets still evaluates the function 100 times:
ArrayFormula(sum(if(randbetween(0,A1:A100*0+99)<25,1,0)))
or
=Sumproduct(if(randbetween(0,A1:A100*0+99)<25,1,0))
The result is each time you force this to re-calculate (by changing something in the range A1:A100 or by setting File -> Spreadsheet Settings -> (Tab) Calculation -> Recalculation to every minute) it will give an answer around 25.
To make it more resilient (allow any value in A1:A100 including error values) could try
=ArrayFormula(sum(if(randbetween(0,iferror(A1:A100/0,0)+99)<25,1,0)))
or
=Sumproduct(if(randbetween(0,iferror(A1:A100/0,0)+99)<25,1,0))
I don't know why I didn't do this in the first place
=ArrayFormula(sum(if(randbetween(0,row(A1:A100)*0+99)<25,1,0)))
then this easily allows for a variable range
=ArrayFormula(sum(if(randbetween(0,row(indirect("A1:A"&H1))*0+99)<25,1,0)))
where the number in H1 doesn't have to be limited to the number of rows in the sheet.
Okay so I found a very convoluted answer. If someone finds a better please let me know.
The first thing as the user |'-'| commented was to create a range on separate sheet.
Since I know that I will not be looking up more than 200 values at once I created my range to be 200 long of this formula.
=IF(RAND()<0.25,1,0)
This will create the initial list of random values.
The next step is you need to generate a randomizer seed. Which is basically a random number between the range you created. You can do this with
=RANDBETWEEN(1,200)
This should be on the same column as what you are trying to sum up later.
Next you want to create a dynamic string that you can access via arrayFormula later.
="Randomizer!B"&B12&":B"&B12+B3
In my case I had the 200 random numbers on a sheet called randomizer. Notice the &, this is how you connect strings. In my example B12 is the reference to the =RANDBETWEEN(1,200), and B3 is how many times I want the randomness to occur. It can be any value as long as it's less than the randomizer seed by the amount of times you want it to be random.
Finally refer to this string using, =SUM(ARRAYFORMULA(INDIRECT(B13))) , indirect lets you refer to a string as a cell and this is how I was able to create a dynamic range to calculate from.
I will say the advantage of this method is its super fast to calculate since the random numbers have been pre-computed.
The idea is that it will keep creating random ranges from the precomputed random numbers you created, and then summing those ranges, essentially calculating random numbers n'th amount of times.
Hope this helps someone.

Getting Average m:s:ms time in Google Sheets

I am working on a Google Sheets file in order to get Track and Field Data.
The times run by the athletes are:
1:58.66
2:00.03
2:00.31
2:01.85
2:03.07
2:03.18
2:03.57
... etc.
In total I have 141 values. I have tried looking for functions to help me with this, but it seems as though these values are not accepted as numbers.
I need the average of all 141 times.
There is no direct way to get this done in excel, but you can achieve it using the following function (assuming your data is stored in column A)
=ARRAYFORMULA(sum(60*left(A1:A)+right(A1:A,5)))/COUNTA(A:A)
So, I used arrayfunction to go through the whole list at column A and converted it into seconds, then divided it by its count (using COUNTA for non-numeric values) to get the average seconds for all athletes.
You can export date in mm:ss.00 format again using this function,
=TEXT(B1/(24*60*60),"mm:ss.00")
Please note that TEXT function receives value (in days), hence you will have to divide the first function result (assumed it is at B1) by 24*60*60.
enjoy...

Lookup and calculation with mulitple criteria also based on a cell value

I'm trying to create a spreadsheet that will allow me to quickly calculate the amount of time my trains were delayed on a daily basis.
I need a formula that will check for all trains on a particular route after a planned departure time (written in a cell),check these trains actual arrival time and then display the earliest possible time I could have arrived at my destination.
spreadsheet image
For example, in G4 I would like a formula that looks for all trains that depart after 7:49 (A4) and also match both of it's "From" and "To" (C4 & D4). It would then need to check these trains corresponding "actual arrival times" in column F and show the earliest possible train. So for row 4 this would be 9:36.
Any help would be really appreciated as I have been messing around with this for over a day and have gotten nowhere!
A link to the example is here - https://docs.google.com/spreadsheets/d/1eE8t4-_hKB6o5j3W57EHgKzsF9p1usm7nojerjmrDwY/edit#gid=0
Thanks
Oli
Not sure about 9:36 Do you mean 9:39 ?
It's a little difficult to do this but i think what you are looking for is a multiconditional lookup array. I have put below what I think you are trying to achieve.
If A2:A8 is greater than A4, C2:C8 = C4 and D2:D8 = D4, what is the lowest value in F2:F8
Is this correct?
If so then I came up with this formula:
=ArrayFormula(MIN(IF((A2:A8>A4),IF((C2:C8=C4),IF((D2:D8=D4),F2:F8)))))
If you get 0.402 or something, format the cell to time.
Otherwise, could you break it down for us a bit more?

Resources