Google Sheets - SUMIFS using date ranges as criteria shows wrong values - google-sheets

I am creating a financial overview tool in which I want to make sums of income/costs/profit - all summarised based on the month of the year in which those business cases were finished.
I ran into a problem with the SUMIFS formula not showing a correct value. Some months show correct value using a first formula, some only using the second, etc.
Google Spreadsheet Link (all important numbers are randomised)
I tried three options : (February as an example)
=SUMIFS(input!H3:H200;input!M3:M200;">"&DATUM(2022;1;31);input!M3:M200;"<"&DATUM(2022;3;1))
=>>This way I wanted to limit the SUMIF by only choosing cells with date > January but < March
=SUMIFS(input!H3:H200;input!M3:M200;">"&DATUM(2022;2;0);input!M3:M200;"<"&DATUM(2022;2;31))
=>>Limiting the SUMIF by choosing cells with date range higher than 2022/2/0 and lower than 2022/2/32 (unreachable dates)
=SUMIFS(input!H3:H200;input!M3:M200;">="&DATUM(2022;2;1);input!M3:M200;"<="&DATUM(2022;2;31))
=>>Limiting the SUMIF by choosing cells with date range higher and including 2022/2/1 and lower + including 2022/2/31 (unreachable dates)
Why didnt i just refer to a cell with the sum already calculated? Because the input list is an excel export from our crm platform which is never the same and I want to create something that does the work for me.
Why didnt I use index + vlookup to simply find the sum value based on the keyword "month name" + column number? Because I need to use a similar formula as sumifs in the next columns that are not shown yet. If there is no direct solution to my problem then I will resort to using the index+vlookup.

Changing the dates on the months that don't coincide solves the issue.
For example for May:
February 2022 had 28 days but on the function for May you used the 31st of february:
=SUMIFS(input!G3:G200;input!M3:M200;">"&DATE(**2022;2;31**);input!M3:M200;">"&DATE(2022;4;1))
and the result is:
If instead I change the March function to:
SUMIFS(input!G3:G200;input!M3:M200;">"&DATE(2022;2;28);input!M3:M200;"<"&DATE(2022;4;1))
The result gets corrected as it should.

Related

Match and count in a vacation tracking sheet

My team has a vacation tracking calendar in Google Sheets. I'm trying to create a formula (for the red cells) to automatically count the number of days entered in the calendar by person and absence code.
I've tried a number of different ways to solve this using Countifs, Match and Index but it only works for a single range, yet I need to count one range for each month of the year.
Is there an easier way to do this than adding 12 similar formulas together.
Assuming you don't need a spill range you could just do a basic countif off of a filtered range on the name.
so if your data starts on A8 and goes all the way to column f (you'd want more), and you put the exact string you're searching above the cell in row 3, this should work:
=countif(filter($A$8:$F,$A$8:$A=$C3),D$2)
Here's a sample sheet from screen shot.

Exact same formula producing two different results depending on cell in google sheets

I'm making a calendar heat map of my org's sessions per day. There might be easier ways to do it, but I have one sheet for a calendar, another listing every single session by day, and the heat map sheet that looks at the equivalent calendar cell and counts how many sessions match that date. Conditional formatting changes the colour of the date cell depending on the number. Screenshot of sheet setup. (sorry, can't imbed images)
Each cell on my heat map matches a cell on the calendar sheet, so each heat map cell contains:
=countif(Sessions!$A:$A,'Calendar 2021'!B5)
with the cell address changing for each date.
It all looked good until one date cell returned the wrong count for that date. When I checked the formula for that date, I found that it did return the right count - when I copied it to a different cell.
It's the exact same formula in each cell :
=countif(Sessions!$A:$A,'Calendar 2021'!C23)
but in columns A-L, it returns '3', and after column M it returns '4' (the correct result).
screenshot of different results
Any idea what's causing that?
If it's useful to have a look yourself, here's a version with the same problem (stripped of all data but the dates): https://docs.google.com/spreadsheets/d/16xP_a_KgeIoqomdsk3kMUDuV2GyIVMoNoOusvfWJdNU/edit?usp=sharing
You have different formatting applied to the various cells: none of which are correct for your use, by the way.
In the cells producing a result of 3, you have formatting set to "d". This means you're requesting that the format show the day of the week instead of the underlying number (meaning that the only possible returns for this formatting are the numbers 1 - 7). Since your underlying correct number is 4, the d formatting assumes that 4 is a raw date. The date-time origin in Sheets is December 30, 1899, which corresponds to the number 0. So 4 would translate to January 3, 1900. And the day of the week (d) of that date was a Tuesday, which in Sheets, is day 3 of the week counting from Sunday ... hence your formatted return of 3.
In the cells returning 4, it is only a happy accident that they are; because you've got the formatting for those set to return a date-time. As it so happens, the raw number 4 is the same as the 4th day from the origin date in Sheets; so you happen to be getting a formatted return of 4.
You should be selecting the entire range A:R in your heat map sheet and setting the formatting to simply '0', which means "the original raw number." Setting the formatting this way will not affect text, only numbers.
I should note that your formatting and data types in your sample sheet are all over the place. Some of your numbers are generated by formula. Some are raw dates. So when you set the whole thing to formatting 0, many of your cells are going to show numbers in the 40000 range, corresponding to the number of elapsed days for the underlying date as marked from December 30, 1899. You'll need to be sure that every applicable cell in your heat map sheet contains a formula that returns the COUNTIF, not dates.

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.

How to Count Timestamp on Google Spreadsheets?

My responses are timestamped as soon as anyone submits a survey. I wanted to count those timestamp monthwise.
URL - https://docs.google.com/spreadsheet/ccc?key=0AkpZp6MVqYv1dE5SZjJIODB1WF9nZDR6b1ZJZjFPenc&usp=sharing
I wanted to find out number of positive responses for a particular question (lets say Q1) for a particular month (lets say May)
Column G is not founded out based on the timestamp of Q1, I had asked the user the month, but that's not the correct way to do so, so I have stopped asking the user to enter the month.
First you have to overcome the fact that the timestamp isn't compatible with googles date format. No biggie,... luckily it looks like you have a fixed format ie DD/MM/YYYY. So you can use the LEFT and RIGHT formulas like so =right(left(a2,5),2) This will give you the month in text, ie 05.
Great.
Now for the harder stuff. If you have the newer google spreadsheets, you can simply use countifs to the effect of:
=countifs(arrayformula(right(left(A$2:A,5),2)),"=05",B$2:B,"=Positive")
For each month, replace the "=05" with the the date number you want. You could also make a month lookup chart for all months and questions so that you don't have to modify the formula for each month and quesiton. For this you replace the "=05" with =[cell number containing month number as text] (NOTE: for making a lookup key, you will have to pay close attention to the fact that you are getting TEXT in the formula above vice a number. There is a difference and they are not compatible as-is.)
Let's say you don't have the new google spreadsheets. Then you can use the old sumproduct() and if(). Yes, it is old. See the following:
=sumproduct(arrayformula(if(right(left(A$2:A,5),2)="05",1,0)),arrayformula(if(B$2:B="Positive",1,0)))
Note in both of these, you need to use arrayformula to convert the column with the timestamp into something useable. If you want to make this part easier by removing the parseing functions (LEFT() and RIGHT()) you need to change the timestamp format to be MM/DD/YYYY. Then you can plug in the the MONTH(DATE) formula and it will be done.
Then make a master sheet like so (note my formula has a "'" in it to make it visible for purposes of demonstration, you should remove it.):
Careful inspection might note that the count is wrong. That is because when I imported your timestamps, times like "02/06/2014 ..." were interpreted to mean "February 06" because of google's auto-formatting. In your sheet you will get the correct count using this formula, because of the way your timestamp is auto-populated.
HINT: To make the month a text you need to enter ="05" in the Month column
Please let me know how you make out.

Resources