Here is a generic version of the formula we are working with:
=AVERAGEIFS ( [Average Range] , Active_User, = TRUE, START_YEAR, [Cell A1] )
In Cell A1, we want to allow the user to select a specific year (2016,15,14) as well as select ANY Year (*).
Is there a string can we put into Cell A1 that will function as a wildcard?
We've tried * ; "" ; "20*" - also tried changing the fixed reference to something like "="&[A1] or ">="&[A1]. All return Div#0
Realize that this can be done by dropping the START_YEAR criterion from the formula, but we would like to avoid using VBA to modify the formulas. This is in a table with multiple similar AVERAGEIFS so there would be many items to modify.
Have you tried something like ">1900"? This would look for any date after 1900, which should cover all eventualities... assuming you're not analyzing 19th century events.
Related
I have the following formula that uses Named Ranges:
=SUM(COUNTIFS(BuildingNameLeases,A22,
Lease_Move_In_Date,"<"&$T$1,
vacated_date,{""","<"&$T$1-2"}))
It is not working and I don't know how to fix it.
It should be finding count of all building names [BuildingNameLeases] that match A22 where the move in date is before the date in T1 and the vacated date [vacated_date] is blank or 2 days before T1
Your last parameter is the problem. Arrays must be either ranges such as A1:B7 or absolutes such as {4,"hello",7,"world"}. They cannot contain cell references such as {T1,L7}.
To apply the logic you stated, you could do:
=SUM( (BuildingNameLeases=A22) * (Lease_Move_In_Date < $T$1) * (ISBLANK(vacated_date) + vacated_date < $T$1-2) )
I have 1 workbook with 2 worksheets.
The first screenshot shows Worksheet A, the second screenshot shows Worksheet B
I would like to match the corresponding quantity to the corresponding grade in Worksheet A based on the Columns "Line", "Sub-Line", "Category", "Occasion", "Sub-Cat" and "Grade" in Worksheet B.
Question: How to get the corresponding quantity?
Many thanks!
Since you already have a concatenation of the search criteria in SheetB!F:F you might use this formula if you have Excel 365 (much earlier versions won't have the TEXTJOIN function).
=VLOOKUP(J2, SheetB!$F$2:$K$1000, MATCH(I2,SheetB!$F$1:$K$1, 0), FALSE)
Witness that the MATCH function includes F1, which must not have any of the captions found in G1:K1. $K$1000 is an arbitrary row number intended to be larger than anything you need. For use in my own project, I would create a dynamic named range instead of SheetB!$F$2:$K$1000.
This is a little heavy and perhaps someone can make an easier approach, but let's give it a go. NB: This requires Excel 2019 or 365.
You can put this into your QTY column in WORKSHEET A:
=SUM(TRANSPOSE(MMULT(SIGN(SEQUENCE(1,5)),TRANSPOSE(--(B5:F5=WorksheetB!$A$3:$E$14)))=5)*INDEX(WorksheetB!$G$3:$K$14,,MATCH(G5,WorksheetB!$G$2:$K$2,0))
That's hard to read, so here it is again with formatting (it works with formatting all the same):
=SUM( TRANSPOSE( MMULT( SIGN( SEQUENCE( 1, 5) ),
TRANSPOSE(--(B5:F5=WorksheetB!$A$3:$E$14) ) ) = 5 )
* INDEX( WorksheetB!$G$3:$K$14,,MATCH( G5, WorksheetB!$G$2:$K$2,0) ) )
Seems there would be an easier way, but it does not come to me at the moment.
As a side note - what you are doing looks very much like something that could be done in Power Query. It would make quick work of doing such match-ups and aggregations and if there is a lot more that you want to do with these data, it would support that as well.
You can use INDEX and MATCH for this:
=INDEX('Worksheet B'!$G$4:$K$26,MATCH(1,($B5='Worksheet B'!$A$4:$A$26)*($C5='Worksheet B'!$B$4:$B$26)*($E5='Worksheet B'!$C$4:$C$26)*($D5='Worksheet B'!$D$4:$D$26)*($F5='Worksheet B'!$E$4:$E$26),0),MATCH($I5,'Worksheet B'!$G$3:$K$3,0))
The formula needs to be entered with ctrl+shift+enter as it's an array formula.
It indexes the quantities in 'Worksheet B'!$G$4:$K$2 and returns the row number of where the value in Worksheet A of the line, sub-line, occasion, category, sub-cat matches the value in the resembling column in Worksheet B and the indexed column number of where the grade value in Worksheet A equals the header in Worksheet B'!$G$3:$K$3.
This worked for me!
=VLOOKUP(CONCAT(B10,"-",C10,"-",E10,"-",F10,"-",D10),'Worksheet2'!$F$4:$K$26,MATCH('Worksheet1'!M10,'Worksheet2'!$F$3:$K$3,0),FALSE)
Cheers
I have the opposite query for this question:
Excel - Lookup to return multiple values in between date range
The solution is given for the above query in the following link also:
https://www.get-digital-help.com/2009/12/13/formula-for-matching-a-date-within-a-date-range-in-excel/
But my query is that for multiple date ranges, how do I find the total bookings of a single date.
I wish to build a calendar which will allow me to work out how many booking I have for a certain day. All the bookings are for 1 or more items and I want the total items which will be there on a single day, across a date calendar range.
On the calendar on the right side, I wish to add the total items which will be staying over during that specified date.
So, in the example, on the 26th December, a total of 6 items will be there. And for 5th December there is only 1, while for 1st December there are no items.
Would like to have these numbers in the calendar on the right.
I have tried using VLOOKUP, LOOKUP, INDEX and MATCH.
Also, tried the SUMPRODUCT mentioned, but those seem to give a single range and number for that range, but not the multiple values across a date range.
https://chandoo.org/wp/range-lookup-excel/
Formulae I tried are, for the 26th December date are:
=(LOOKUP(H10,((Table1[Date From]):(Table1[Date To])),Table1[Items from]))
=SUMIF(Table1[Item],(LOOKUP(2,1/(Table1[Date From]<=H10)/(Table1[Date To]>=H10))))
=INDEX(Table1[Item from],MATCH(H10,LOOKUP(H10,Table1[[Date From]:[Date To]])))
For Dec 26th (and keeping your original structure)
=SUMIFS(Bookings[[Items]:[Items]],Bookings[[Date From]:[Date From]],"<=" &H10,Bookings[[Date To]:[Date To]],">="&H10)
Note that I used the absolute address structured reference form so you can at least fill/drag across a row, without changing the columns from the table.
If you want to make things even easier, you can replace the H10 reference with a computed reference, but at the cost of using OFFSET which is a volatile function.
=SUMIFS(Bookings[[Items]:[Items]],Bookings[[Date From]:[Date From]],"<=" &OFFSET(H$1,ROW()-2,0),Bookings[[Date To]:[Date To]],">="&OFFSET(H$1,ROW()-2,0))
You might also be able to construct a computed cell reference using the INDEX function, which would be non-volatile.
Updated answer with array formulas
Sorry for not understanding your first request.
You can use the following array formula in a "single cell"
{= SUM( IF( (E2 >=$B$2:$B$8 ) * (E2<=$C$2:$C$8) ; $A$2:$A$8 ; 0 ))}
Where column e contains the target dates, columns a, b and c contain items, from and to.
This formula is expansible and copiable to other cells where e2 will be relatively changed for each target date. This is easily adaptable to your month table. Put the formula below the first date, then expand horizontally and copy/paste to the other rows.
See picture:
Old answer
Create a separate cell with your target date. Suppose $e$1.
Create on e2 this formula: =if( and( $e$1 >= c2 ; $e$1 <= d2 ); a2; 0)
Expand it and sum at the bottom.
Sorry for my formulas in Portuguese in the image (se = if ; e = and):
I've been Googling for hours trying to create a COUNTIFS formula that will:
count the unique records in a table range
that have dates that fall within 4 years after
a year in a referenced cell
This is what I have so far: =COUNTIFS(dte_degr_conferred2,"<="&YEAR('Student Success and Progress'!$G$1)+4) but it is not correct and I've tried several variations
Please note: dte_degr_conferred2 column contains dates, 'Student Success and Progress'!$G$1 contains a 4-digit year
Many Thanks
Perhaps you mean this array formula**:
=SUM(IF(FREQUENCY(IF(dte_degr_conferred2<>"",IF(YEAR(dte_degr_conferred2)='Student Success and Progress'!G1,dte_degr_conferred2)),dte_degr_conferred2),1))
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
Trying to work out exactly what you need (you might be overcomplicating). Here is an example of using the COUNTIFS formula to compare dates. This formula was entered into cell E6 with the setup as below:
=COUNTIFS($B$2:$B$6,"<="&E3+4,$B$2:$B$6,">="&E3)
I have an even more simplistic interpretation:
=COUNTIF(dte_degr_conferred2,">="&DATE('Student Success and Progress'!$G$1+4,1,1))
The "count unique" requirement makes this an interesting question.
Here's what I've come up with:
=SUM(
IF(
FREQUENCY(
IF((YEAR(ddc)>=ssp!$G$1) + (YEAR(ddc)<ssp!$G$1+4) = 2, ddc, ""),
IF((YEAR(ddc)>=ssp!$G$1) + (YEAR(ddc)<ssp!$G$1+4) = 2, ddc, "")
)>0,
1
)
)
... where ddc is dte_degr_conferred2 and ssp is 'Student Success and Progress'. (When posting to SO, it's helpful to reduce a question to its essentials, because that makes it easier to respond to, as well as making it more universally useful.)
Enter as an array formula: Ctrl + Shift + Enter
Example
In this example, there are three distinct dates that match the criteria: 05/12/2014, 09/12/2014, and 05/26/2012.
How it works:
When creating array formulas, it can be useful to work out the calculations separately before joining them in an array. I've done so here:
Column C is =(YEAR(A1)>=$B$1) + (YEAR(A1)<$B$1+4) (copied down). In Excel, TRUE is 1 and FALSE is 0, so you can add boolean values together. If A1 is between B1 and B1+4, both operands are TRUE, and TRUE + TRUE = 2.
Column D is =IF(C1=2,A1,"") (copied down). This grabs the data that matches the criteria. (I formatted as numbers to highlight the fact that Excel stores dates as numbers.)
Column E is =SUM(IF(FREQUENCY(D1:D10,D1:D10)>0,1)). For an explanation of this method, see http://office.microsoft.com/en-us/excel-help/count-occurrences-of-values-or-unique-values-in-a-data-range-HP003056118.aspx
My solution at top combines all this into a single array formula.
I've got 3 columns as follows:
Boolean Value Date
Yes £3000 01-Jan-2012
No £3000 01-Jan-2012
No £3000 01-Nov-2012
Basically I just need to look at that table and come up with the total value for where Boolean is set to No, however only take those where the month is equal or less than the current month set by the computer time
Which version of Excel? In Excel 2007 and later try SUMIFS which allows you to sum with multiple conditions, i.e.
=SUMIFS(B2:B10,A2:A10,"No",C2:C10,"<="&TODAY())
I used cell references but you can used named ranges in their place like this:
=SUMIFS(Value,Boolean,"No",Date,"<="&TODAY())
or in earlier versions of Excel you can use SUMPRODUCT like this:
=SUMPRODUCT(B2:B10,(A2:A10="No")*(C2:C10<=TODAY()))
Use the DSUM function.
Criteria range would be
Boolean Month Check
No =MONTH(C2) < X
where C2 is the first data cell in column Date.