Excel - find nth match - excel

I created a like to follow the inventory on an item.
I'm looking to find "What's the next date of availability?"
I found my answer with a index match function, but the problem is :
For each orders, what's available to promise... when my Running Total is not covered by the next "stock Arrival" how to find the "2nd" best match (next arrival)..
Maybe I'm overthinking this..
Here is my workbook :
https://drive.google.com/open?id=0BwbUB7pydqnfemQwQW9JaFoxbGs
Anyone is an Excel guru?

You can check edited file. This formula is very comlicated, but it takes into account that, what would be if the second
Put this array formula and press CTRL+SHIFT+ENTER and fill down:
=IF(K2=0,INDEX(A3:E$17,MATCH("05 - arrival",A3:A$17,0),5),IF(SUM($G$2:G2)+INDEX($G$2:$G$17,SMALL(IF($G$2:$G$17>0,ROW($G$2:$G$17)),1)-1)+INDEX($G$2:$G$17,SMALL(IF($G$2:$G$17>0,ROW($G$2:$G$17)),2)-1)>0,INDEX($E$2:$E$17,SMALL(IF($G$2:$G$17>0,ROW($G$2:$G$17)),2)-1),INDEX($E$2:$E$17,SMALL(IF($G$2:$G$17>0,ROW($G$2:$G$17)),3)-1)))
Hope this will help.

I think you're looking for the next instock date? For example, L2 shows the next arrival date is 11/25/16, but on that date you can clearly see that it will be Not Instock. So, instead you would like to tell the customer when it will be instock - see column M - which shows the date of the next instock arrival date.
To do this, I used a 'adjusting' range INDEX() and MATCH() formula: =INDEX(E2:$E$17,MATCH("Instock",I2:$I$17,0))
Notice there are no $ dollar signs around E2 and I2. This will allow the range to adjust as the formula is copied down, making sure the previous dates are not in the formula (only present and future dates - nothing from the past).

Related

How to filter out long term events that fall between two dates in Excel 2010?

I'm trying to filter out events that may fall between a certain time period. These events are more than one day, so they have start dates and end dates.
I think the closest example to what I'm looking for is from this link: https://www.extendoffice.com/documents/excel/4647-excel-extract-records-between-two-dates.html. The only difference is that the data in Sheet 1 also have a start and end date that are greater than a day in difference, rather than existing for a singular day.
=IF(ROWS(A$5:A5)>$C$2,"",INDEX(Sheet1!A$2:A$22,SMALL(IF((Sheet1!$A$2:$A$22>=$A$2)*(Sheet1!$A$2:$A$22<=$B$2),ROW(Sheet1!A$2:A$22)-ROW(Sheet1!$A$2)+1),ROWS(A$5:A5))))
The issue is that currently the start dates may not coincide with the bounds of the study dates, but that the end dates of the data in Sheet 1 do fall within these bounds.
An example of what I'm hoping to do is this:
Example:
However, instead of having the date just be a single day, I'm hoping for a way to sort through data that have a start and end date.
This solution seems to work:
Assuming in Sheet1, columnA and columnB contain Start and End dates respectively.
Change the formula in C1 of Sheet2 to this, and follow the other instructions as given in your example.
=SUMPRODUCT((Sheet1!$A$2:$A$22>=A2)*(Sheet1!$A$2:$A$22<=B2)*(Sheet1!$B$2:$B$22>=A2)*(Sheet1!$B$2:$B$22<=B2))
Note: If this is not the output you expect then please share your expected input and output instead of from the sample.
Edit:
Based on your sample image I have updated the formulas. Hope this helps.
Formula for cell H2:
=SUMPRODUCT((($B$2:$B$16>=F2)*($B$2:$B$16<=G2)*($C$2:$C$16>=F2)*($C$2:$C$16<=G2))+((B2:B16<F2)*(C2:C16>=F2)*(C2:C16<=G2))+((B2:B16>=F2)*(B2:B16<=G2)*(C2:C16>G2))+((B2:B16<F2)*(C2:C16)>G2))
Formula for cell F5:
=IF(ROWS(F$5:F5)>$H$2,"",INDEX(B$2:B$16,SMALL(IF((($B$2:$B$16>=$F$2)*($B$2:$B$16<=$G$2)*($C$2:$C$16>=$F$2)*($C$2:$C$16<=$G$2))+(($B$2:$B$16<$F$2)*($C$2:$C$16>=$F$2)*($C$2:$C$16<=$G$2))+(($B$2:$B$16>=$F$2)*($B$2:$B$16<=$G$2)*($C$2:$C$16>$G$2))+(($B$2:$B$16<$F$2)*($C$2:$C$16)>$G$2),ROW(B$2:B$16)-ROW($B$2)+1),ROWS(F$5:F5))))
Don't forget to press Shift + Ctrl + Enter when using formula in F5.
And then extend to other cells.
Output:

IF Function Query - Extended

I got an answer for a previous question regarding an IF function on my excel tracking sheet.
I would like to further this by adding another formula to the existing formula.
I am looking for some help regarding an IF function on an Excel
document.
Basically if the Date Listed cell is dated over 1 month ago (eg: Date
Listed 6-Aug but today is 6-Sep) and the Date Sold cell is blank, then
I would like the Mark Down cell to say 'MARK DOWN', which at the
moment it does but it is only 10-Aug today.
If the Date Listed cell and the Date Sold cell both contain dates I
would like the Mark Down cell to say 'OK'.
So far I have this written:
=IF(AND(DATE(YEAR(G2),MONTH(G2),DAY(G2)), ISBLANK(H2)),"MARK DOWN","OK")
I know I'm not far off but I need help sorting out the
last parts..
Bonus if you can help me add a highlighted cell formatting to it :)!
Example Image
******Original formula:
=IF(AND((TODAY()-G11)>31,ISBLANK(H11)),"Mark Down","No")******
My additional query is:
If this item hadn't been uploaded yet, therefore there would be no date in the Date Listed cell, I would like to have an ISBLANK function which returns with "Not Required".
I have read something about ampersands and joining functions but not sure how to use them properly.
Here is what I have so far:
=IF(AND((TODAY()-G19)>31,ISBLANK(H19)),"Mark Down","No"), OR(ISBLANK(G19)),"Not Required")
Thanks again.

Formula "IF ANY" (basically a for each)

Hello I'm wondering if there's a formula equivalent of an for each statement.
I know this would be possible with VBA, but given it's an official report I'd prefer to make it macro-free.
Basically I have a column (let's say A) that contains when an invoice was paid
`
|----------------------------------|
1|DUE DATE (TABLE HEADER, COLUMN A) | (COLUMN B)
|==================================|
2|1/1/2019 | =If any of the due dates are past today, trigger
3|2/5/2018 |
4|4/5/2018 |
Now let's presume we have the current date (22/2/2018) as you can see, none of these are past the due date.
I have a cell in column B with the following formula
=IF(DATEDIF(TODAY(), A2:A4, "d")">0", "All invoices paid in time", "Invoice past the due date found"
Issue is, DATEDIF can only work with individual day, not a range. Technically I could do it with multiple OR formulas -> eg.
=IF(OR(DATEDIF(TODAY(), A2 "d"), DATEDIF(TODAY(), A3, "D")...and so on......
but this would be only viable in my example, not in document with 500 due dates.
Any idea how to exute this?
TL/DR: I'm trying to create a formula, for a cell, that if any of the due dates are before today, i want the cell to trigger to a different value
There is, sort of. Enter the powerful world of arrays:
Suppose your dates are in A1:A3. And the test date is B1. B1 might contain the (volatile) formula =TODAY().
You use the array formula
=IF(SUM(IF(A1:A3 > B1, 1, 0)), 1, 0)
remembering to press Ctrl + Shift + Return to declare this as an array. Essentially the IF is evaluated cell by cell in the range A1:A3. That's remarkably for-each-like.
There are other techniques for this particular case, but the answer I give you is, I think, the pattern that generalises most readily.
Use the MIN() function. If MIN(A:A) is less than TODAY() then at least one item is past due.
Well Technically I found a way to make this work, but this is more of a workaround, rather than proper answer to the formula in question.
If you create a (hidden) column like this
with the formula
=IF(ISNUMBER(DATEDIF(A2, TODAY(), "d"), 1, 0)
Basically, the way DATEDIF works it tries to substract two dates. However, since Excel is not normally capable of getting negative dates (exception with Date System 1904 enabled). If it gets a negative date, it will produce #NUM! error, so the ISNUMBER formula acts like a trigger criteria in this function.
Then we simply create our control cell
With the following formula
=IF(SUM(B:B)>0, "ALERT: " & SUM(B:B) & " invoices are past the due date", "No invoices past due date yet")
The way this works is quite simple. If our datedif triggers, it goes to 1, by adding (SUM) all the triggers together we achieve the amount of the invoices that are past the due date (invoices where the due date triggered). For better illustration:
Now, let's say 2/3 invoices would be past the due date, then it would produce the following result:
Hopefully this helps :)
You can try this array formula:
= OR(A1:A3>B1)+0

Trying to find the last non-empty cell in a specific row/range over multiple sheets

I looked at a couple suggestions here and didn't find something that specifically worked for me. I would prefer not to use an Array Formula if possible. However, if that's the only way, I'll try to work with it.
I am working on an attendance workbook of sorts in Excel 2013. The workbook contains a Calculations sheet, a Lists sheet and a sheet for each month of the year. The Lists sheet has a list for names and a list for the months. I have included a link to a sample workbook to demonstrate how the sheets are setup and the basic functions, names, lists, etc that I am using.
My sample workbook:
https://app.box.com/s/mgvums1vmnmnec7e7d0p4vi5daoyo5nv
When looking for the last non-empty cell in a specific row/range, I receive the correct result when I use the following LOOKUP on each specific Month sheet: (Which I found after some digging on a few sites) =LOOKUP(2,1/(C5:AG5<>""),C$4:AG$4)
- For the Month of Feb, the last entry in the range C5:AG5 is in AA5, which is the 25th.
I also receive the correct result when I use the following Lookup from any non-Month sheet: =LOOKUP(2,1/(Feb!C5:AG5<>""),Feb!C$4:AG$4)
That being said, the two specific issues I am running into, are as follows:
I have been unable to work out how to come up with the last non-empty cell (which is the last marked day of attendance) when using Name and Month information selected in the Combo Box/Form Controls. Simply said, in my sample workbook, I want to know the last day in Feb that Johnny was in attendance.
I've tried starting simple, just using the "Month" I selected. I tried a few different itterations of the following:
=LOOKUP(2,1/(Month&"!C5:AG5<>"""),Month&"!C$4:AG$4")
The closest I've gotten was the above Lookup, which ends up turning into what you see below (when viewed in Calculation steps). It of course returns a #VALUE! error.
=LOOKUP(2,1/"Feb!C5:AG5<>""",Month&"!C$4:AG$4")
I also tried this Array Formula and it gave me a result of 4. Which, isn't the proper result. And, I don't know where the result actually came from.
=MAX((INDIRECT(F4&"!"&"C5:AG5")<>"")*(ROW(INDIRECT(F4&"!"&"C$4:AG$4"))))
I have been unable to work out how to come up with the last non-empty cell across all the Month sheets when using the selected Name from the Combo Box/Form Control. Basically, I want to know the last day of the year that Johnny was in attendance. In this sample workbook, that would fall on April 11th. I understand that the formula would just return "11". I believe I can format the result after the fact, using the resulting sheet name. (In this sample case, Apr)
I am fairly certain I will need to use a VLOOKUP. I just can't seem to break the barrier between the general concepts of what I want and the proper way of formulating it.
Any help would be appreciated. I'm feeling pretty lost at the moment. If you need more info from me, please let me know.
Thanks,
Kurewe
The key is to use INDIRECT with the exact same LOOKUP formula you already had and use the MATCH formula to determine the row number for the selected name.
Place the following formulas:
G3: =MATCH(F3,NameList,0)+4 (find the item number of the selected name within NameList)
H2: =F4&"!C4:AG4" (construct the address for the date row for the selected month)
H3: =F4&"!C"&G3&":AG"&G3 (construct the address to use for the selected name and month)
E9: =INDEX(MonthList,ROW()-ROW(E$8)) copy down to E20 (find the name of the month for this row using MonthList)
G9: =E9&"!C4:AG4" copy down to G20 (construct the address for the date row for the month in E9)
H9: =E9&"!C"&G$3&":AG"&G$3 copy down to H20 (construct the address to use for the selected name and the month in E9)
F9: =IFERROR(LOOKUP(2,1/(INDIRECT(H9)<>""),INDIRECT(G9)),"(n/a)") copy down to F20 (find the last day with an "X" in it using the addresses in G9 & H9)
G4: =LOOKUP(2,1/ISNUMBER(F9:F20),ROW(F9:F20)-ROW(F8)) (find the index of the first cell with "(n/a)" in it)
F5: =LOOKUP(2,1/(INDIRECT(H3)<>""),INDIRECT(H2)) (find the last day with an "X" in it for the addresses in H2 & H3)
F6: =INDEX(MonthList,G4)&"-"&INDEX(F9:F20,G4) (construct the date of the last day of attendance within the year)

I need to count number of dates in a range, that when compared to one specific date are more than a particular number of days (56 in my case)

How I see it what I need is =countif(C:C,"datedif(12-09-2015,C:C,"d")>56")
My best guess is that within the datedif brackets I can't enter a date as C:C.
I keep getting an error message or a zero.
What I want to achieve is to have a monthly (1-30/31) table that shows how many people were working on that day that had been there for more than 56 days. So the end table would look something like this:
use array =SUM(IF()) instead of =COUNTIF()
Firs of all create an IF finction that return TRUE when your conditions are met:
in cell F2 put: =IF("20/09/2015"-C2:C12 > 56) and confirm with CTRL+Shift+enter to create an array formula
you should get: TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE
once you know it works as intended, you can just wrap it in a single-cell sum. In cell G2 put: =SUM(IF("20/09/2015"-C2:C12 > 56)) and confirm with CTRL+Shift+enter. You will have a single cell this time, with a result of 3
This should be enough to get you started. In your case I suggest you store the "1,2,3,4,5..." day numbers in results sheet as dates, formatted to display just the day number, and then reference that directly in each countif

Resources