Averaging data across multiple columns based on criteria (excel) - excel

I have a spreadsheet (Office 365 Pro) that has numeric data in multiple columns. I want to average data in those columns if specific multiple criteria is met in other columns.
For example, one formula that is in use:
=AVERAGEIFS(K:K,C:C, ">=01/01/2021", C:C, "<=1/31/2021")
This formula works exactly the way I want, for the data specifically only in column K.
I want to accomplish what this formula does, but to include columns K through P, and not K only.
I tested a simple average formula which worked fine across multiple columns
=AVERAGE(K:P)
I can't figure out how to average data in all of those columns based on the criteria in my other formula.
If I simply change the column to average to:
=AVERAGEIFS(K:P,C:C, ">=01/01/2021", C:C, "<=1/31/2021")
I get a #VALUE error.
Any suggestions on how to accomplish this?

use FILTER:
=AVERAGE(FILTER(K:P,(C:C>=DATEVALUE("01/01/2021"))*(C:C<=DATEVALUE("1/31/2021"))))

Related

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)

Excel: Count Unique Dates for set of multiple criteria

I have a large spreadsheet with many data columns and dates . Column B is the date column and there are multiple rows of duplicate dates with different data in the following columns. I'm trying to write a formula to give me a count of how many unique dates there were given different criteria. I did this formula entered as an array and it worked perfectly.
=COUNT(1/FREQUENCY(IF(('NA Trades'!D:D="TSX D3")*('NA Trades'!DX:DX>16),IF('NA Trades'!B:B<>"",'NA Trades'!B:B)),IF(('NA Trades'!D:D="TSX D3")*('NA Trades'!DX:DX>16),IF('NA Trades'!B:B<>"",'NA Trades'!B:B))))
I tried expanding on this and adding more criteria but it doesn't seem to be working and giving me a result of 0. This is the array formula I tried with the added criteria
'=COUNT(1/FREQUENCY(IF(('NA Trades'!D:D="TSX D3")*('NA Trades'!DX:DX>16)*('NA Trades'!DQ:DQ<-2.6),IF('NA Trades'!B:B<>"",'NA Trades'!B:B)),IF(('NA Trades'!D:D="TSX D3")*('NA Trades'!DX:DX>16)*('NA Trades'!DQ:DQ<-2.6),IF('NA Trades'!B:B<>"",'NA Trades'!B:B))))
Where did I go wrong with the second formula and how can I format this formula so I can continue to add more criteria?
Your formula seems to be working fine, are you sure you have the correct data in your newly added column? BTW, I would suggest that you use named ranges or a table - it's easier to read.

Sumproduct for conditional sum based on rows and columns

I have table formatted as show below:
I'd like to write conditional sum formula in cell F15 to calculate sum based Year, Country, Product together.
I try to use sumproduct to complete this task, but I was only able to calculate sum based on 2 variables: Year and Country.
=SUMPRODUCT((A3:A11=C15)*(C1:Z1=E15);C3:Z11)
Is there a way how to add 3rd variable into this sumproduct formula? Or is there another way to complete this task (I can't change formating of the table).
I didn't have a problem when I tried it - as long as the first part of the SUMPRODUCT works out to an array with the same dimensions as the second part, it should be OK.
=SUMPRODUCT((A3:A11=C15)*(B3:B11=D15)*(C1:Z1=E15);C3:Z11)

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

Averaging Highest Three Values of multiple cells in Excel

I have two columns of data. I need the formula to pull the three highest values from both columns and average them.
55,000.00
87,769.12
85,839.97
56,650.00
58,349.50
60,099.99
61,902.98
63,760.07
65,672.88
67,643.06
These values will change and the formula needs to analyze all of the cells constantly to pull the three highest and average. Any help would be appreciated! Thanks!
This formula will do this:
=AVERAGE(LARGE($A:$A,ROW(A1:A3)))
You need to enter it with Ctrl-Shift-Enter.
In your specific example, use this formula:
=AVERAGE(LARGE((C11:D13,M12:N18),ROW(1:3)))

Resources