#REF! (Reference does not exist) error after sort - google-sheets-formula

I'm probably making a really simple mistake here but I can't figure it out. I'm making a simple spreadsheet that tracks runners' last 5k time and then I take their time away from the slowest runner to give a 'handicap' time. This way all the runners should finish the race together next time.
Here's the data:
And the formula is
= MAX(D2:D16) - D2
When I do a sort (by the calculated start time column, I get the #REF! error (Reference does not exist. Like I say it's probably really simple, but I can't figure it out. Any help appreciated!

The formula you are using in F2 should be =MAX(D$2:D$16)-D2, otherwise it won't even work when you drag it down. And sorting it with from the menu obviously won't do anything, since if it's a formula you dragged down, it will autoupdate to still use the same row from column D. There is however a sort function you can use either in a different column (like in G2 =sort(F2:F16,1,1)) or you could change your F2 formula to =SORT(ARRAYFORMULA(MAX(D$2:D$16)-D2:D16),1,1), so both sorting and propagation down the column are done in one.

Related

matrix report grand total vary with each time its rows increase or decrees

I made a matrix report in oracle which works fine after that I made grand totals out of the repeating frame but in main frame which works fine but only thing is that when column increase or decrease its position on report changed mean which column I made total it goes sometime faraway I want that totals field also change there position with matrix column any idea about that if anyone knows that what can I do for thanks in advance
Punctuation exists for a reason; I suggest you use it. You wrote the whole message as a single, loooooong sentence which is difficult to read and understand.
Anyway, the way I understood the problem, it looks as if you'd have to anchor totals' fields to something; can't tell what exactly. Might be matrix columns, maybe their enclosing frame ... try and see which of these works properly.

ARRAYFORMULA summing column with previous recursively for all columns

Let's say my formula is in D2. I want to sum the value from previous column with another sheet column and do it for all rows, I can do the following:
=ARRAYFORMULA(C2:C+AnotherSheet!D2:D)
Now I would like the next column to do the same:
=ARRAYFORMULA(D2:D+AnotherSheet!E2:E)
How would I set it up, so it works for all columns without manually copy pasting this formula to the next column.
This quick and dirty brute force formula might be some help, depending on how many columns you need. Try this:
=ARRAYFORMULA({C2:C+Sheet2!D2:D,
C2:C+Sheet2!D2:D+Sheet2!E2:E,
C2:C+Sheet2!D2:D+Sheet2!E2:E+Sheet2!F2:F,
C2:C+Sheet2!D2:D+Sheet2!E2:E+Sheet2!F2:F+Sheet2!G2:G,
C2:C+Sheet2!D2:D+Sheet2!E2:E+Sheet2!F2:F+Sheet2!G2:G+Sheet2!H2:H})
It wouldn't be too hard to automatically generate the full formula you need, if your number of columns isn't changing all the time.
But I imagine someone will come up with an elegant formula to somehow do the same thing. Let us know if this helps.

How do I compare times without hours?

I am admittedly bad at formulas so I apologize if this comes off as stupid:
I need to compare two times for my swimmers and can't figure out a clear way to write a formula to compare their time vs. a cut time they are shooting for.
Ex:
Swimmer has a 2:44.01 in her event, and needs a 2:41.96 for a specific meet.
In this instance, her time is in B3 and the cut time is in C3. How do I write a formula that will display the difference in those times in cell C4, right below the cut time?
Everything I have seen requires a hh:mm:ss.00 formula or similar but how do I write it so that I don't have so many stinkin 0's in each cell? I wish that it would allow a simple mm:ss.00 without needing hours to register as time.
My other issue is that in C4, where I want the difference to show up, how do I start that equation? Do I start with SUM or ELAPSED or what? I'm out of my league here so please help!
try:
=TEXT(VALUE("00:"&B2)-VALUE("00:"&C2), "m:ss.00")
...and format all fields as Plain text

Algorithm for animating elements running across a scene

I'm not sure if the title is right but...
I want to animate (with html + canvas + javascript) a section of a road with a given density/flow/speed configuration. For that, I need to have a "source" of vehicles in one end, and a "sink" in the other end. Then, a certain parameter would determine how many vehicles per time unit are created, and their (constant) speed. Then, I guess I should have a "clock" loop, to increment the position of the vehicles at a given frame-rate. Preferrably, a user could change some values in a form, and the running animation would update accordingly.
The end result should be a (much more sophisticated, hopefully) variation of this (sorry for the blinking):
Actually this is a very common problem, there are thousands of screen-savers that use this effect, most notably the "star field", which has parameters for star generation and star movement. So, I believe there must be some "design pattern", or more widespread form (maybe even a name) for this algoritm. What would solve my problem would be some example or tutorial on how to achieve this with common control flows (loops, counters, ifs).
Any idea is much appreciated!
I'm not sure of your question, this doesn't seem an algorithm question, more like programming advice. I have a game which needs exactly this (for monsters not cars), this is what I did. It is in a sort of .Net psuedocode but similar stuff exists in other environments.
If you are running an animation by hand, you essentially need a "game-loop".
while (noinput):
timenow = getsystemtime();
timedelta = timenow - timeprevious;
update_object_positions(timedelta);
draw_stuff_to_screen();
timeprevious = timenow;
noinput = check_for_input()
The update_object_positions(timedelta) moves everything along timedelta, which is how long since this loop last executed. It will run flat-out redrawing every timedelta. If you want it to run at a constant speed, say once every 20 mS, you can stick in a thread.sleep(20-timedelta) to pad out the time to 20mS.
Returning to your question. I had a car class that included its speed, lane, type etc as well as the time it appears. I had a finite number of "cars" so these were pre-generated. I held these in a list which I sorted by the time they appeared. Then in the update_object_position(time) routine, I saw if the next car had a start time before the current time, and if so I popped cars off the list until the first (next) car had a start time in the future.
You want (I guess) an infinite number of cars. This requires only a slight variation. Generate the first car for each lane, record its start time. When you call update_object_position(), if you start a car, find the next car for that lane and its time and make that the next car. If you have patterns that you want to repeat, generate the whole pattern in one go into a list, and then generate a new pattern when that list is emptied. This would also work well in terms of letting users specify variable pattern flows.
Finally, have you looked at what happens in real traffic flows as the volume mounts? Random small braking activities cause cars behind to slightly over-react, and as the slight over-reactions accumulate it turns into cars completely stopping a kilometre back up the road. Its quite strange, and so might be a great effect in your wallpaper/screensaver whatever as well as being a proper simulation.

optimal algorithm for adding chosen table rows to the database

I am trying to apply a save method in a backing Java bean which will take the table rows that are selected and save them in the database. However, let's say the user changes his choices a little (changes 1 out of his 5 choices). I am wondering about the algorithm I am going to apply if it matters in efficiency in the long term or not....
here it goes :
every time the user clicks the button (save) I will delete all his previous choices and insert all the current choices to the database
once the button is clicked --- see which rows the user de-selected and delete their rows from the database and add the new ones???
is choice number 2 better or not than choice 1 .......or it doesn't really matter for number of choices that will not exceed 15 ??
Thanks
I would definitely go for option 2, try to figure out the minimum number of operations you need to perform.
It is, however, fairly normal to fall back to option 1 in times of deadlines etc. since it is a bit easier to implement.
There shouldn't, however, be that much harder to figure out what the changes are, since it doesn't seem to me that you're changing the rows themselves. Either you're deleting ones that had their checkmark cleared, or you insert ones that had their checkmark set.
Simply store a list of primary key values of whatever is in the database, then compare to that list when you iterate through the new list when the user wants to persist the changes.
A minimal work solution here would also mean you would be a bit more future-proof in terms of refactoring, changes, or additions. For instance, what if there in the future is data attached to any of those rows. You would need to keep that as well. Generally I'm a bit opposed to writing code just for the sake of "what if", but here I feel it's more like "why wouldn't you ..." than that.
So my advice is go for option 2. Not much more work.

Resources