SUMIF COUNTIF AVERAGE problem formula...

NJS1982

Board Regular
Joined
Sep 24, 2009
Messages
179
Hi all, hoping that somebody can help with this formula please...

I have a list of contractors, all with multiple lines for queries (for different pieces of work), with the number of days they take to respond to each query and the fiscal year that the query falls into.

So I have the following columns:

L = Contractor name
S = Number of days to respond
AD = Fiscal year (i.e. 2018/2019).

I then have a drop down elsewhere in the sheet with 'All Years' or the fiscal year (so it can be changed) and a summary table with each contractor in (listed in column B down).

The formula I have come up with is:
=IF($B$2="All Years",
SUMIF($L$21:$L$504,B11,$S$21:$S$504)/COUNTIF($L$21:$L$504,B11),
SUMIFS($L$21:$L$504,B11,$S$21:$S$504,$AD$20:$AD$504,$B$2)
/COUNTIFS($L$21:$L$504,$B$10,$AD$21:$AD$504,$B$2))

However it is throwing out a #Value ! error and I can't see why that would be? In the above example, B11 contains 'ABC'.

I am trying to say, if B2 = All Years, then look at all of the contractors listed in column L, tell me the number of times 'ABC' appears and the number of cumulative days to respond, then divide that by the number of times 'ABC' appears in the column (to get the average).

HOWEVER, if B2 = anything other than 'All Years' (i.e. a specific fiscal year period, like 2018/2019), then do the same calculation but factor in the number of instances the contractor appears in that financial year alone.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,771
Office Version
365
Platform
Windows
One thing that stands out is is looks like your SUMIFS is not structured correctly:
Code:
[B][COLOR=#ffa500]SUMIFS($L$21:$L$504,B11,$S$21:$S$504,[U]$AD$20:$AD$504,$B$2)[/U][/COLOR][/B]
I think your second argument should be a whole range, not a single cell.
See here for the proper structure: https://exceljet.net/excel-functions/excel-sumifs-function
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,771
Office Version
365
Platform
Windows
You are welcome.
 

Forum statistics

Threads
1,085,513
Messages
5,384,111
Members
401,881
Latest member
Dato

Some videos you may like

This Week's Hot Topics

Top