Extracting year with max value for calendar day Google Sheets - google-sheets

I have a sheet with daily readings of lake level and temperature. I want to extract the max level for each day of the year, along with the year that the reading occurred. If it occurred more than once on the same day of the year, I'd like the first occurrence. It's easy enough to get the max for each day, but I haven't been able to also extract the year. I'm sure there are other people much more versed in GSheets than me who can figure this out. I also expect it's not that difficult, but I've yet to be able to find something that works.
Here's the sheet:
https://docs.google.com/spreadsheets/d/1kC3L0oDpnnJlFFuB76mUXiz3vGcfT5_fC3YbkE9Xgsg

UPDATE:
The layout you needed was a little different than what I'd first thought.
This QUERY will generate the maximum and minimums per day for your data.
link to sample sheet
=ARRAYFORMULA(QUERY({1*(TEXT('raw data'!A2:A,"mmm d ")&2020),IF('raw data'!B2:C=0,,'raw data'!B2:C)},"select Col1,MAX(Col2),MIN(Col2),MAX(Col3),MIN(Col3) where Col1 is not null group by Col1 order by Col1 label Col1'Day'"))
Then this formula will use those days and values to do a VLOOKUP back into the Raw Data to show the first year on which that value occurred for that day.
=ARRAYFORMULA(VLOOKUP(N(C4:D)&TEXT(B4:B,"mmm d"),{'raw data'!B:B&TEXT('raw data'!A:A,"mmm d"),YEAR('raw data'!A:A)},2,0))
This spreadsheet will be available forever.

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))))))

Calculating average for more than one month of data

I am writing some formulas that will make up a dashboard that allows for a dynamic look-up of change in waiting times for admission into a hospital. In this case, what I want to do is create a lookback period of 1 month, 3 months, 6 months, and 1 year to see how waiting times have changed during this time at a few locations. It's a bit of a complex issue, but the stripped down data and my example code can be found here (fully shared for editing).
I have successfully gotten the correct formulas for finding 1 month worth of change, but how to apprroach more than 1 month's worth of data eludes me and this is especially problamatic because the date formatting is not standard excel/google sheets data format. As this data will be continously fed into the spreadsheet, I don't think I have the option to modify it either so I think the only option is to come up with some pretty funky formulas that treat months as text. Alternatively, I guess I can also try to make a formula that reformats the text into valid google sheets dates and then use that to make calculations but then while I could probably write that formula, I'd still not know how to get multiple months worth of data processed. Can anyone help take a look at the sheet? (feel free to copy/edit the file if necessary).
try like this:
=QUERY({INDEX(SPLIT(Data!A3:A, "T"),,1), Data!B3:C},
"select avg(Col3)
where Col1 >= "&DATEVALUE(EOMONTH(TODAY(), -4)+1)&"
group by Col2
label avg(Col3)''")
spreadsheet demo

Formula Trouble in Google Sheets

I have a raw export of data, categorized by rows, amount, and date.
I'm having difficulty finding/combining various spreadsheet formula's to get the the total expenditure in say "Jan'20 for category XX"
I have currently tried a combination of Sumif/Index/Match formulas with no luck. Some assistance would be greatly appreciated.
EDIT#1:
Link to the google sheet is here
You seem to have the correct numbers on your main page so the formulas which total for each month, and by each category, seem to be working properly. I noticed that your pivot table wasn't sorting correctly. this turned out to be because you had your date values in the Month column on the Export tab set as string values. I converted these to date values, equal to the last day of the given month. I did the same for the month headers on your Main tab.
Now the pivot table sorts by month correctly, since these are now numeric values.
See here for a sample sheet.
https://docs.google.com/spreadsheets/d/1pmTgKqFZmKiP0k0iKDWGQlWVyKJF5PfglhcwhRj49Y4/edit?usp=sharing
If there is still an issue you need help with, please let us know, with the details.

Find Number of Days in Current Month That Fall Between Date Range In Google Sheets

I'm trying to come up with a function that will calculate a monthly budget from within a specified date range. I tried to use SUMIFS but I can't figure out how to isolate a specific month within the range.
Example:
We have a sheet with Google Ad campaigns, with a row for each campaign.
We are running one Google Ad campaign (A) from 2/15/20 to 5/15/20 with a total budget of $3000 from which I calculate a daily budget of $33.33.
We are running a second campaign (B) from 5/15/20 to 8/15/20, also with a budget of $3,000, from which I calculate a daily budget of $32.61.
=IF(NOT(ISBLANK(Start_Date)),Total_Budget/(End_Date-Start_Date),"")
In a separate sheet, I have Budget and Spend fields for each month. For May, I need it to calculate the total budget for 5/1-5/15 of Campaign A, and 5/15-5/31 of Campaign B.
I got this far (J is the Daily_Budget, G is the Start_Date, and H is the End_Date):
=SUMIFS(Google!J2:J30, Google!G2:G30,"<="&DATE(2020,5,1),Google!H2:H30,">="&DATE(2020,5,31))
Then I was at a loss for how to extrapolate the number of days from the range, so that I could then multiply them by the Daily Budget and then add them together.
I thought of going back to the sheet that contains the campaigns and adding columns for each month with a complicated conditional, and then just using SUM(), but I feel like there has to be a more elegant solution.
UPDATE
Per request, here is a link to the spreadsheet with the desired results manually entered: Click here. May & June show the campaign partial month overlaps. The result I'm ultimately going for is =(15*Google!J2)+(16*Google!J3).
UPDATE 2 (24Jun20)
Per request, I have shared the spreadsheet so that people can make a copy and experiment with formulas: Click here..
Any ideas?
Thanks,
Ty
I would use the function DATEDIF() (documentation here). You can set the first parameter as the first day of the month you are trying to calculate the number of days within it, and the second as the first day from another month. Example:
DATEDIF(DATE(2020, 1, 1), DATE(2020, 2, 1), "D")
You could probably make a custom function with this as well to input only the number of each month (and year, in case of leap years on February), but I don't have much experience with that unfortunately.

getting a count and sum total for the latest date by category in real time

My original data looks like this:
Original Data
I'm looking for a way for my query to return information ONLY for the latest date associated with each Test. For that date, I am looking to get the count number of customers and the $ Paid total. What's complicating my effort is the fact that multiple people could take the Test at a given date and across dates.
The ideal results should look like something like this:
Ideal Results
I am getting information submitted into this table via Google Forms in real-time hence row range will be dynamic & need a solution that can give me the info I am looking for at any given time.
Here is the one that came the closest for me (although still far off as it does not show the Count or the Total $):
=ARRAYFORMULA(VLOOKUP(QUERY({ROW(A2:A),SORT(A2:D)}, "SELECT MAX(Col1) WHERE Col3 IS NOT NULL GROUP BY Col3 LABEL MAX(Col1)''",0),{ROW(A2:A), SORT(A2:D)},{2,3,4,5},0))
Spreadsheet link for Original data and the results of the above query:
Google Spreadsheet with Original Data
I would really appreciate any insights or help from anybody.
Possible solution (based on your document)
https://docs.google.com/spreadsheets/d/1tADqNS4YtdDrMjToCNy2auKB_eNuMdMEA4ahmYJi_3M/edit?usp=sharing
Details:
Lastest date for a test could be found using FILTER MAX functions
Count for a test (at lastest date) could be found using COUNTIFS
Sum for a test (at lastest date) could be found using SUMIFS

Resources