Return a SUM from multiple sheets - excel

I have a formula that returns values from multiple sheets under certain criteria and provides the sum.
=SUMPRODUCT(IFERROR(SUMIF(INDIRECT("'"&B17&" "&Year&"*'!C:C"),"Total",INDIRECT("'"&B17&" "&Year&"*'!Z:Z")),0))
I am looking to return a value that is correlated to Total, but since there are multiple Totals on each page I get back the sum of them all. I only need one Total (that is listed as 100%) from each sheet rather than all of them.

Linking spreadsheets is inherently fragile.
If you do it, then to minimise fragility:
use named ranges for your target cells.
bring them to your consolidating spreadsheet as single numbers - then sum them there.

=SUMPRODUCT(IFERROR(SUMIFS(INDIRECT("'"&B17&" "&Year&"*'!Z:Z"),INDIRECT("'"&B17&" "&Year&"*'!C:C"),B19,INDIRECT("'"&B17&" "&Year&"*'!AA:AA"),"100%")/COUNTIFS(INDIRECT("'"&B17&" "&Year&"*'!C:C"),B19,INDIRECT("'"&B17&" "&Year&"*'!AA:AA"),"100%"),0))
This is the solution I came up with. Changed to SUMIFS to make criteria more detailed searching for "Total" (which is B19) and "100%". Then divide by COUNTIFS using the same criteria as SUMIFS since each sheet has different amount of Total rows

Related

What formula can I use to search a value and add cells two rows over across multiple sheets?

I am trying to add values across sheets and an having a hard time finding a good formula to do this with.
I have over 300 sheets, representing rooms, that have two relevant columns, one that has dates and another with water consumption usage that look like this:
enter image description here
Issue is, the dates are inconsistent across all of the sheets. The full range of dates should be from 1/13/2023 to 2/6/2023 but many sheets are missing dates because water consumption wasn't read that date.
I have a summary page with a column representing the full range of dates and another column where I want to add usage for the specific date across all the sheets to show how much water was consumed that day across all rooms. Since the dates and usage are all in different cells, I can't call out specific cells. What is the best formula to use and how can I format it correctly?
I tried SUMIF formula's as well as IF formulas and tried nesting variations of them, but ultimately I am having trouble finding a formula/formatting that allows me to call out a cell value (ex, 2/6/2023) and sum the value two columns over. I am fairly new to the more advanced formula's so please forgive my ignorance.

Excel Sumifs using numbers stored as text in criteria

I am trying to use the SUMIFS() formula in excel to exclude certain rows from a table, but the criteria range includes numbers stored as text.
In the picture below I want to exclude the rows where entity id is "101000". The SUMIFS() formulas I have tried all provide the incorrect solution.
I found similar problems (here and here). This is where I came up with the SUMPRODUCT alternative.
I am trying to see if there is an alternative using SUMIFS. The syntax of SUMPRODUCT is confusing. But more importantly it doesn't work if I have entity id's that both translate to the same number value ('0100' and '00100').
If you are using Office 365 you can combined the FILTER and SUM functions.
First FILTER the amounts
=FILTER(C4:C9,B4:B9<>"01000")
Then SUM the filtered amounts
=SUM(FILTER(C4:C9,B4:B9<>"01000"))
You can sum the rows whose IDs do match, and then subtract it from the total sum:
=SUM($C$4:$C$6)-SUMIF($B$4:$B$6,"101000",$C$4:$C$6)

How can I automatically number rows in Excel based off two different criteria, one being date?

I am attempting to automatically number rows in Excel based on "grouping" first by 'category', then by 'date'. I have manually applied numbers in the image to illustrate what I am looking for.
!
I have exhausted all vanilla Excel options I know if; ideally this can be achieved without any macros.
You can use COUNTIFS with a dynamic range:
=COUNTIFS(A$2:A2,A2,B$2:B2,B2)
Here I'm using a range that increases in size as the formula is copied down, notice the row number is locked with $.

Sorting formulas issue

I have a table which consists of names (1st column) avarageifs (2-6 columns) and average formulas (7 column).
Averageifs formula is taking the name to average values for each name:
=IFERROR(AVERAGEIFS(Grades!B:B,Grades!$A:$A,Rankings!$B14),"N/A")
"Total" average formula is:
=IFERROR(AVERAGE(C14:G14),0)
Then I am trying to sort it by "total" average, formulas are mixing up and referring to different rows.
But it should refer to the same row. What happens after sorting and how can I fix it?
Basically the references in the AVERAGEIFS formulae are getting swapped around and you don't want this to happen.
The easiest way round it would be to put the Totals column next to the Names column and just sort these two columns, leaving the other formulae in place.
If you don't want to do that, a fairly quick and dirty solution is to replace the AVERAGEIFS formulae with this so they always refer to the current row:-
=IFERROR(AVERAGEIFS(Grades!B:B,Grades!A:A,INDIRECT("Rankings!$B"&ROW())),"N/A")
See the discussion here

Is there a way to calculate the cost (time and memory) of excel calculations?

For example, if I need to decide between making one column an array formula or making two additional sumif columns then adding them together, how can I make a good decision?
You can use the RangeCalc addin downloadable from http://www.decisionmodels.com/downloads.htm
This gives you accurate timing of the calculation of the selected cells, so you can compare calculating the array formula with 2 SUMIF columns (the SUMIF columns will probably be faster)

Resources