SUM on multiple dynamic criteria on a separate sheet in google sheets - google-sheets

I am attempting to write a formula that will sum values across multiple rows from a separate sheet based on multiple criteria. If it helps with context, the report will be a cashflow statement that sums up the different account types and displays them together on a dashboard. Here is a copy of the workbook I am using:
published or
shareable
For example, in the linked workbook, for Cell B9 on the Dashboard sheet I want to sum all of the Credit Card - Credit Card values for the month of Sep 2022 from Practice A.
I've been able to write a formula that will return only the first value it finds for the criteria, not a sum of all the values. Here is what I currently have in B9:
=IFNA(SUM(INDEX(INDIRECT(B$3&"!$A$10:$ZZZ"),MATCH($A9,INDIRECT(B$3&"!$B$10:$B"),0),MATCH(DATEVALUE($F$1),DATEVALUE(INDIRECT(B$3&"!$9:$9")),0))))
It returns the first value for those criteria (-$33,863.01) on the Practice A sheet for Sep 2022 rather than the sum of all rows matching the criteria (-$51,261.69) on the Practice A sheet for Sep 2022.
Any and all help / feedback is appreciated!
Thanks, Daniel

formula is:
=SUM(FILTER(FILTER('Practice A'!C10:Z, 'Practice A'!C9:Z9*1=
EOMONTH(F1, -1)+1), 'Practice A'!B10:B=A9))
with indirects:
=SUM(FILTER(FILTER(INDIRECT(B3&"!C10:Z"), INDIRECT(B3&"!C9:Z9")*1=
EOMONTH(F1, -1)+1), INDIRECT(B3&"!B10:B")=A9))
with some tweaking it could be written as:
=LAMBDA(x, SUM(FILTER(FILTER(OFFSET(x,,,9^9, 24), OFFSET(x, -1,,,24)*1=
EOMONTH($F1, -1)+1), OFFSET(x,,-1, 9^9)=$A9)))(INDIRECT(B3&"!C10"))
or even arrayformula like:
=BYCOL(B3:F3, LAMBDA(y, LAMBDA(x, SUM(FILTER(FILTER(OFFSET(x,,,9^9, 24), OFFSET(x, -1,,,24)*1=
EOMONTH($F1, -1)+1), OFFSET(x,,-1, 9^9)=$A9)))(INDIRECT(y&"!C10"))))

Related

COUNTIFS not returning correct count

I have a Google Sheet with two tabs: Output and Data. Output has a layout of results/aggregations and data has the information I used. I want to count all instances of two texts in a Data column and return that in Output but my formula is not working. I'm not sure what I'm doing wrong. Please help.
In this example, the value from the formula in C2 of Output sheet should be two since there were two resources created in January of 2021 as per the Data sheet.
Data Sheet
Output Sheet
use:
=ARRAYFORMULA(COUNTIFS(Data!B:B, "*"&D2:D21&"*", Data!B:B, "*"&E2:E21&"*"))

Google sheets: Is there a way to quickly/easily add a date range to ~300 cells each with different countifs formulas?

I am using the countifs function to add up a lot of different conditions - I need help to simplify the process so that it doesn't require so much manual formatting every time.
Here is a screenshot of a hypothetical spreadsheet. Here is a hypothetical scenario that will help convey my question. Let's say I am working with 3 clients, Macy's, abercrombie, and gap, to fill several open positions. We are reviewing multiple candidates. When I have reviewed them and approved, I select "yes" in the verdict column (E). When they have been processed, I selected yes in the F column. If I do not approve them, I select No in the column. So on and so forth.
So now I'd like to keep track of how many candidates I've approved and processed for each client for each open position. Here is my spreadsheet for that. I have used the countifs function from the previous spreadsheet, called "Review Document" as follows:
Column C, Row 2 - counting sales associate for abercrombie who have been approved and not yet processed:
=COUNTIFS(
'Review Document'!$B:$B,"abercrombie",
'Review Document'!$C:$C, "sales associate",
'Review Document'!$E:$E,"yes",
'Review Document'!$F:$F,"no")
I essentially do this for every single client, for every single role, for both column C and D. Imagine that there are ~300 rows with different companies and roles - The formula text changes every time to count if "position" and "company".
What I would like to do is now find an easy way to automatically apply a date range to all of these cells, without having to manually add a date criterion for every single formula. For example, in the first spreadsheet, there are dates in Feb, Mar, And April. Is there a way to apply a date range on my second spreadsheet so that it only counts the dates I specify? E.G. - apply some date range to ALL cells in that sheet so that it only counts if the date is 2/15/2022-3/31-2022? I would ultimately like to be able to change the date range quickly without having to manually add a date criterion to 300 cells, and then change it every time I want to see the numbers for a different date range. I was tinkering with conditional formatting but I haven't figured it out.
Thanks!
use:
=INDEX(QUERY(QUERY({A2:A, PROPER(B2:C),
IF((E2:E="yes")*(F2:F<>"yes"), 1, 0),
IF((E2:E="yes")*(F2:F= "yes"), 1, 0)},
"select Col2,Col3,sum(Col4),sum(Col5)
where Col1 is not null "&
IF(J1="",," and Col1 >= date '"&TEXT(J1, "yyyy-mm-dd")&"'")&
IF(J2="",," and Col1 <= date '"&TEXT(J2, "yyyy-mm-dd")&"'")&"
group by Col2,Col3"),
"offset 1", ))

Google Sheets formula recalculation quirk

This may simply be a convoluted duplicate of an existing question, and I have been able to find one or two issues that match what I'm seeing here, but I am very curious to see if the cause is just user error on my part or if this is something I am just not aware of.
I have a worksheet titled Sheet1 with 999 rows. On this sheet in cells A3, B3, and C3 down are Year values (2021), Month numbers (1, 2, 3, etc.), and Quarter (Q1, Q2, etc.). In cell D, I have the following long but simple formula:
=SUMPRODUCT((MONTH(INDIRECT("TestSheet ("&C2&" "&A2&")!$C$3:$C$999"))=B2)*(YEAR(INDIRECT("TestSheet ("&C2&" "&A2&")!$C$3:$C$999"))=A2)*(INDIRECT("TestSheet ("&C2&" "&A2&")!$E$3:$E$999")))
What this formula does is sum the monetary values from sheets with variable names by month (INDIRECT is used to refer to sheets with the name "TestSheet (x y)", where x is the Quarter value and y is the year (ie: "TestSheet (Q1 2021)").
This formula functions as intended, and correctly sums the values on the variable sheet names when those sheets exist. The issue I'm running into is that it seems to take a length of time for Sheets to identify that a sheet exists, even when "On change and every minute" is selected under the Calculation tab under Spreadsheet Settings. From testing on a fresh workbook in which this formula is the only one present and there are no other formulas present that could be slowing down the recalculation, the cell values do not appear to update at all even an hour after the relevant cells have been updated with data.
Is there any indication based on what I have so far that stands out as a possible cause? Any suggestions would be appreciated.
try:
=INDEX(SUMIF(TEXT(
INDIRECT("TestSheet ("&C5&" "&A5&")!C2:C"), "yyyyM"), A5&B5,
INDIRECT("TestSheet ("&C5&" "&A5&")!E2:E")))

SUMIF with VLOOKUP based on date range in multiple sheets

I have a sheet called "Orders" in which I add each order, its date and amount.
In a separate sheet, I have a monthly summary table.
I want a cell in the summary table to look at the "Orders" sheet, and if the date (in Orders, row G) falls between Jan 1 and Jan 31, I want the total from Orders, column AE to show in the summary table. I'll do this for each month.
This is what I have so far:
=SUMIF(VLOOKUP(AE4:AE5,'Orders'!G4:G5,">=1-Jan-2021″,G4:G5,”<=31-Jan-2021″),0)
Obviously that isn't right (I'm just playing around and don't really know what I'm doing!), but maybe I'm getting close.
Note that new rows (i.e., orders) will be added to the Orders sheet throughout the year, so I want AE5 and G5 in the formula to update automatically as I add a new row.
Any help much appreciated.
Here's one method, which requires a few more columns but isn't terrible. You could probably shorten this a little, but if you're in a pinch then it works.
In your orders sheet, add two more columns titled "Month" and "Year".
Month Formula (which extracts the numeric month from your date):
Cell C2: =MONTH(B2)
Year Formula (which extracts the numeric year from your date):
Cell D2: =YEAR(B2)
Then in your summary data, you create a SUMIFs formula. Picture below.
Cell K2: =SUMIFS(E:E,C:C,I2,D:D,J2)
If I've not misunderstood your requirement then sumifs (plural) itself can help out,
Conveniently you can have a named range "total" for the column G and "date" for column AE of the orders sheet
If you want to add dates greater than 1st of Dec and less than 5th of Dec then in the cell of the summary sheet you can add
SUMIFS(total,date,">=1/12/20",date,"<5/12/20")
I'm having some problems visualizing what your spreadsheet looks like, but assuming the dates you are checking against are in column G and your totals are in column AE, I think the following would work:
=SUMIFS(AE1:AE1000;G1:G1000;"<="&DATE(2020;1;31);G1:G1000;">="&DATE(2020;1;1))
If I wanted to make this formula to autoexpand as I added more rows to the table, I'd change my data into an actual table, and refer to the ranges by their headers. Or you can just do what I've done here, and set a range that is significantly larger than what you are likely to use and hope you never add any entries outside of it.
Okay, found it! The formula that has worked is
=SUMIFS(Orders!$AE4:$AE5,Orders!$G4:$G5,">=1/1/21",Orders!$G4:$G5,"<=1/31/21")
Thanks for all your help!

Count items in column range if value exists in corresponding row ranges

I have a spreadsheet which tracks weekly meeting attendance. I need to return the number of individuals who attended at least one meeting in the month, not the sum total of weekly meeting attendees. In other words, if a person attended 4 meetings in the month, the count is incremented by 1, not 4.
Names are listed in Column A, and the weeks in the month are listed in columns B-F (e.g. B2 is "Sep 2"; C2 is "Sep 9"; "D2 is "Sep 16", and so on.) When a person attends a meeting, the corresponding cell receives an "X".
So far, the only method I know I can use to return the number of unique or distinct meeting attendees is to first use a set of formulas in one column (H) to return whether an "X" is found in the corresponding rows, and then a second formula that references the range (in column H) containing the first set of formulas to return the number of TRUE results.
What I'm trying to do is use an ArrayFormula or something similar to give me the final number in just one shot. I'm currently using a COUNTIF function on values in a column range while the rows in that very range are populated using COUNTA functions.
How can I use just one formula to return the attendance count - not depending on that intermediary step/range in column H?
I can't seem to get an array formula to work correctly, and I haven't been able to find similar answers despite hours of searching. Apologies if there are similar questions already posted (I couldn't find one asking quite the same question as mine). Here's my best attempt so far:
=ArrayFormula(COUNTIF(COUNTA(B3:F17) > 0,TRUE)) ...which returns 1.
Here is an example spreadsheet with sample data.
In I22 I entered this formula
=countif(ArrayFormula(countif(if(B3:F17="X", row(B3:B17)), row(B3:B17))), ">0")
the formulas in H3:H17 are not used in this formula.
See if that works?

Resources