Conditional sum contigous columns - google-sheets

I'd like to sum the total time allocated per task. Time has been provided either in minutes or in hours.
For example Task A should be:
30 minutes + 2 hours x 60 minutes/hour + 150 minutes = 300
What formula should I use on B2 to get such a result, considering that I have many more than 4 people?

Try
=sumproduct(n(C2:I2)*if(D2:J2="minutes",1,60))

Related

TIme Separator in Google Sheets

I hope everyone reading this is doing well. I am making attendance sheets on Google Sheets that also calculates the salary of the person. It is entirely automated except for one part, the part that calculates salaries.
For that I need to separate the Hours and Minutes worked so that I can calculate the salary accurately based on 60 minutes instead of the first half being in hours and the second from a percentage of 100.
It coverts the hours into days and omits the remaining hours. Please assist. Thank you!
What it does
What it should do
HOUR() returns the hour component of a specific time, so it will always return a value between 0 and 23.
In Google Sheets, times are just numbers where 1 indicates 1 day. So a duration of hh:mm:ss means hh/24 + mm/24/60 + ss/24/60/60 which means hours_in_a_day + minutes_in_a_day + seconds_in_a_day. (You can see this if you format the cell as "Number")
So, if you want to extract the hours from a duration, you have to multiply it by 24 and take the INT().
=INT(B20*24)
Spreadsheet time values such was elapsed hours are in units of days. In your spreadsheet, salary is recorded per hour. To multiply the hours by the salary, first convert the salary per hour to salary per day, and then multiply by the elapsed hours, like this:
=n((B23 * 24) * B20)
The n() wrapper is there just to get the number format right. You can also leave it out and format the formula cell as Format > Number > Currency.
See this answer for an explanation of how date and time values work in spreadsheets.

Filter rows from the last 15 minutes

I need to filter from B to K IF column A is any time in the last 15 minutes from now AND column J says "Yes"
A has the format Hour-Minute-Second, for example "17:20:59". Lets say now is 18:00:00, I want this formula to return all values from 17:45:00 until now.
For now I did this:
=FILTER(B:K, A:A=TODAY(),J:J="Yes")
I need the same but instead of today, the last 15 minutes.
How can I achieve this?
Now returns the time whereas today does not, just subtract minutes / 1440 because that is how many minutes are in a day:
=FILTER(B:K, A:A>=Now()-15/1440+n(whatthefoxsay()),J:J="Yes")

How do I shift Google Sheets duration value from 35:55:00 to 0:35:55?

I have pasted multiple run duration values from Garmin into a Google Sheet. The longer runs (> 1 hour) copy/paste correctly. Eg: 2:10:35. The problem is shorter (< 1 hour) runs. Eg 35:55. The latter are being shown in Google Sheets as 35:55:00. Ie Google assumes 35:55 is 35 hours and 55 mins, not 35 mins and 55 seconds. So for my shorter sub 1 hour durations I need an easy way to convert 35:55:00 to 0:35:55.
As Tom Sharpe said, there is some room for interpretation in the data you have. But assuming that the duration of your runs is always between 10 minutes and 10 hours, we can disambiguate the values as follows:
=if(A1 > 10/24, A1/60, A1)
Numerically, the duration values are measured in days, so A1 > 10/24 means "more than 10 hours". In this case the value gets divided by 60.
Depending on your workout regime you may want to replace the threshold of 10 by another number; perhaps it's safer to say that the runs are always between 5 minutes and 5 hours.

Formula Time * Currency giving strange outcome

I am trying to calculate total wage in a google-spreadsheet by the following formula:
worked hours * hourly rate
However this is giving very strange outcomes, please note the F colum in this example document.
Does anyone know the right way to write this formula?
(I am using euros as currency, i don't think this should matter)
Time is internally stored as decimal number from 0 to 1, where 1 means 24 hours,
thus 2 hours(or 2:00 AM) equals 0.08333... (= 2 / 24)
So, the calculation result is correct: 35 * 0.08333... = 2.91666...
To extract hour from the number, you can use the function HOUR, like this:
=E4 * HOUR(D4)

Ruby / Rails calculation

I have rails 3 application and the following problem. I need to calculate a price based on the following:
Term range from 1 to 365 days (1 year).
Tariffs in a tables which presented in two sections: for one day and for half a month (15 days)
Example 1:
Prices: 1 day price = 0.5 and 15 days = 6
Term : 45 days.
Price: To get the price we devide the number of days by 15 (45/15 = 3) and multiply the result by the tariff for 15 days (3*6 = 18). Final price 18.
Example 2:
Prices: 1 day price = 0.5 and 15 days = 6
Term : 79 days.
Price: To get the price we find the half month period in this case is 45 and again we devide that number by 15 (75/15 = 5) and multiply the result by the tariff for 15 days (5*6 = 30). However there are 4 more days to account for, so we multiple them by the price for a day (4*0.5 = 2). The sum of the two results forms the final price (30+2 = 32).
The period is submited through a from and can be anything from 1 day to 365 days, prices per day and 15 days are stored in a database. My question is how to make the calculations in ruby/rails, so the code always calculates the half month and the reminder if any?
Any help is appreciated.
use the modulo operator:
79 / 15 # dividing integers performs an euclidian division
=> 5
79 % 15 # gives you the rest from an euclidian division.
=> 4

Resources