Cumulative SUMIFS not working - sumifs

I use SUMIFS to calculate a cumulative total of time spent on different work projects in a table. The formula is:
=SUMIFS([Session Hours],[Project],"="&$C5,[Date],"<="&$A5)
Where column A is the Date field, and column C is the Project field. (It seems I can't attach a sample... Maybe I'm missing something?)
But I have a problem. I frequently work on the same project in two different sessions on the same day - and my SUMIFS function adds all sessions to the end of that day, not just to the current row.
I tried various ways of adding in a condition based on the ROW function, but Excel always claimed there was an error in the formula (there wasn't as far as I could tell). Then I tried adding in an INDEX function to specify that the range to be summed went from row 1 of the table to [#Current Row]. This returned a "VALUE" error message.
So, I'm stumped... Any ideas?
This is for MacOS, and the Excel build is 15.33.
Many thanks,
Richard

When working with Excel tables, there are two types of references, structed and explicit. You are using the structured references syntax for the formula, this is equivalent to passing in the entire column.
To get around this, you can convert your formula to use explicit ranges.
For example, if "Session Hours" is in column D then replace [Session Hours] in your formula with something like $D$2:$D5.

Related

Xlookup issue with Indirect function in Google Sheets

I am utilizing a xlookup with indirect references function with certain date ranges to determine the range of rows to search in. With 3k rows of data and repeating values this helped me pair down to non-repeating values so I don't have an errant value from an earlier entry. The xlookup initially worked great when I manually inputted range of rows to search in but when indirect was introduced I am getting my error message I programmed (leading me to believe there isn't an error with my function)
When I utilize the direct references (meaning I'd have to change the date ranges directly in formula) it works great!
`=xlookup(T3,Statistics!F203:F215,Statistics!A203:215,"Not Scheduled",1,1)`
However when I use indirect to reference the specific range (so that I can adjust the date range over one cell and the reference rows recalculate) I get the error message I programmed.
`=xlookup(T3,indirect(Statistics!Q11&":"&Statistics!R11),indirect(Statistics!T11&":"&Statistics!U11),"Not Scheduled",1,1)`
Q11=F203
R11=F215
T11=A203
U11=A215
The correct answer lies in Row F205 which is within the ranges specified in the function.
Usually I figure these out or find a typo when utilizing my functions but I'll be honest and say this has me stumped. The references on the other page are identical. Just for note I also tried a Concateate function to combine the two cells before calling indirect with the same result. Any help would be greatly appreciated as this would add verification to a transportation system instead of double entry across two systems.
As far as I see it, what I think you're missing is the name of the sheet. You're referencing to the cells but not clarifying that the INDIRECT function has to look into "Statistics". Try adding it:
=xlookup(T3,indirect("Statistics!"&Statistics!Q11&":"&Statistics!R11),indirect("Statistics!"&Statistics!T11&":"&Statistics!U11),"Not Scheduled",1,1)
About that 1 after "Not Scheduled", are you sure you don't want an exact match only? Meaning to use a 0 instead of 1

How to get only one of two repeating values

The Issue
In simple terms, I am trying to set a formula for an alternating pattern. The issue I keep running into is the fact that there are two alternating values, and Google Sheets doesn't like to repeat only one of those values without the other.
I have created an example sheet to demonstrate my issue. In Column A, a date is input. Column B and Column C then autofill with the day of the week and AM or PM respectively. Every other value in Column C alternates between AM and PM. I am trying to set it up so that the row is blank until a value in input in Column A. The issue comes when there is an odd number of Dates in Column A. Note that the alternating AM/PM pattern will never change.
What I've Tried
As seen in the image above, there are three main methods that I have tried. The data in C2:C8 is the desired result.
Method 1:
E2: =transpose(split({rept(join(";",{"AM";" "})&";",(roundup(counta(A2:A9)/2)))},";"))
F3: =transpose(split({rept(join(";",{"PM";" "})&";",(counta(A2:A9)/2))},";"))
These formulas work separately, and best represent what I am trying to accomplish, but I have not found a way to combine them to work together in one column.
Method 2:
H2: =transpose(split({rept(join(";",{"AM";"PM"})&";",(roundup(counta(A2:A9)/2)))},";"))
This is essentially the same as Method 1, but put into one formula. The issue here is that Google Sheets doesn't like to repeat half a number of times. So if the number of times to repeat (counta(A2:A9)/2) contains a half (i.e. 3.5), it will still round down to the nearest whole number.
Method 3:
J2: =ArrayFormula(TEXT(SEQUENCE(3),"")&{"AM";"PM"})
This one appeared most promising to me because when incrementing by one, it added one row, but I quickly ran into the issue where if I went over a sequence number of 2, it threw the error Array arguments to CONCAT are of different size.
References
I have used various search terms and websites to try to solve this, and have yet to find something that works. I may be missing something very simple, though, and hopefully this is a quick solution.
Example Sheet:
https://docs.google.com/spreadsheets/d/1I3EtptFLfDHpAQ8AR6Lwa01dSpJ3Cy8MTX1_OjHExSc/edit?usp=sharing
All my formulas are derived from the websites below:
REPT Function in Google Sheets
How to Repeat Multiple Columns N Times in Google Sheets
Delete everything in Col C (including the header) and place this formula in C1:
=ArrayFormula({"AM/PM"; IF(A2:A="",,IF(COUNTIFS(A2:A,A2:A,ROW(A2:A),"<="&ROW(A2:A))=1,"AM","PM"))})
The COUNTIFS finds the number of matches for the date "up to this row" for every row. Since that count will (or should) only ever be a 1 or a 2, the IF makes easy work of assigning "AM" or "PM" accordingly.
If I understand correctly it is enough to use ISEVEN function to alternate by rows:
=ArrayFormula(IF(A2:A,CHOOSE(ISEVEN(ROW(A2:A))+1,"PM","AM"),))

Converting a multi column range into one column

I have an instance where I would love to be able to get a column of all the unique names in a range. The problem I am having is that the range is multicolumn.
Let's assume my data is in A1:B3
This works fine if I do:
=unique({A1:A3;B1:B3;C1:C3})
But if that range is named and I do
=unique(NamedRange) or =unique(A1:C3)
Then it will spill over the column. Worse if I want to filter or sort the results in the same formula and then run into errors because the formulas want single column/row or the rows/columns don't match anymore.
I don't deal with named ranges a lot, but I did just make a formula today that had 10 columns in it that I stuck into a range like that so that I could do a complex (for me) filter that gave me the difference of two different ranges, similar to: =FILTER({B4:B93;C4:C93;D4:D93;E4:E93;F4:F93}, NOT(COUNTIF(H5:H, {B4:B93;C4:C93;D4:D93;E4:E93;F4:F93}))). I would REALLY love if I could clean that up and make that messy set B4:F instead.
Is there any formula level function that could stick these all in one column?
Usually I am looking to do other things with it like sort and filter and the multiple columns get even messier.
Thanks for your time. I DID try searching for this, but I could not seem to find the answer.
Use FLATTEN:
=UNIQUE(FLATTEN(A1:C3))
or
=UNIQUE(FLATTEN(NamedRange))

In array formula, find last specific value up till each row

I have a Google Sheets in question. Here is a mocked version that you can copy or comment on: https://docs.google.com/spreadsheets/d/1szcfZt_CtE0Cd_evKJwN4enZE7JcmDFcw9XhoX-_mlw/edit?usp=sharing
The sheets comes with 2 columns, Test number and Test result. I'd like to use array formula to automatically fill column C whenever new tests are entered. The specification is that the number in column C should always refer to the last "Fail" test number up till each row. You can see the expected result in column E.
I can come up with many solutions that require a formula to be applied to each new cell, which I think is iterative approach. One example is in column G. The reason is that "up till the current row" can't be met with array formula. I tried QUERY function with no success. I know App Script can do this too, but that's not auto fill approach as well.
EDIT: Added a brute-force solution, which can only work with limit number of consecutive "Pass" results.
Please see the screenshot for a solution using an array formula.

SUMIF with FIND as criteria

I'm trying to summarize data from several Google spreadsheet' sheets in a single one but I have some issues with SUMIF and FIND.
To Sum data from another sheet I have to use this (at least that's the only solution I've found)
=SUM(INDIRECT(""&A6&""&"!E2:E"))
Where I have the name of my sheet on A6.This makes everything easy because I have a column (A) with all the names of the sheets. I haven't found something like Sheets[1] in Google Docs.
My next step was to Sum Times from a specific column but remove a specific values, which in this case is 1 that get transformed internally 24:00:00 since it's a time column:
=SUM(INDIRECT(""&A6&""&"!D2:D")) - SUMIF(INDIRECT(""&A6&""&"!D2:D");"24:00:00")
Here I tried to do everything with a single SUMIF but I have no idea how. NOT("24:00:00") didn't work so I settled to this.
The last part is the most difficult and I'm not able to solve it.
I have a column with month names (for example) and I want to sum some data only when the month name contains "er". Here is what I thought:
=SUMIF(A6:A16,ISNUMBER(Find("er")),G6:G16)
This gives me always 0
(Note that the last one contains A6:A16 instead of the whole INDIRECT part because I am still testing it in a single sheet.)
Any Idea what I'm doing wrong?
I don't know why the above SUMIF doesn't work, what I've tested and works is:
=SUMIF(A6:A16,"*er*",G6:G16)
SUMIF is NOT SUM + IF as I thought. I hope it will help someone else.

Resources