Get the latest date in two different tables and return the corresponding value - excel

I'm trying to get the latest date in two different tables and return the corresponding value in excel.
This is what I would want it to be like:
I'm new at excel so I've just been looking all over the internet for a solution but cant find anything.

Posted an an Answer, as confirmed by OP its working for them:
Try either of the one:
• Formula used in cell A6
=#CHOOSECOLS(SORT(VSTACK(A1:B4,D1:E4),1,-1),2)
Or,
• Formula used in cell B6
=INDEX(SORT(VSTACK(A1:B4,D1:E4),1,-1),1,2)
• Formula used in cell D6
=TAKE(SORT(VSTACK(A1:B4,D1:E4),1,-1),1,-1)

Related

Excel formula to lookup a table from another table with comma separated output

I am trying to get a formula that looks up information from another table and populates the output with comma separated values. As shown below, I want to populate column D in Table 2 with information from Table 1. The desired output is in column E. I came up with this formula but it's only pulling one city per person.
TEXTJOIN(", ",,INDEX('Table 1'!B:B,MATCH(FILTERXML(""&SUBSTITUTE(C3,",","")&"","//m"),'Table 1'!A:A,0)))
For you reference, you can see the screenshot below,
Solution as posted by Scott Craner Sir using FILTERXML()
• Formula used in cell G8
=TEXTJOIN(", ",,FILTER($B$3:$B$9,ISNUMBER(MATCH($A$3:$A$9,FILTERXML("<m><b>"&SUBSTITUTE(F3,", ","</b><b>")&"</b></m>","//b"),0)),""))
Note: Depending on one's Excel version this may needs to be keyed with CTRL+SHIFT+ENTER instead of Enter when exiting edit mode.
Perhaps, if you are using MS365 then you can use ARRAYTOTEXT() with TEXTSPLIT() as well,
• Formula used in cell G3
=ARRAYTOTEXT(FILTER($B$3:$B$9,ISNUMBER(MATCH($A$3:$A$9,TEXTSPLIT(F3,,", ",1),0)),""))
Kindly change the cell range/sheet preferences as per your suit.
Edit
Thanks! It appears to be working now. However, there is one down side that I am hoping you can help with. If there is only one person listed, it's returning a #calc error. This formula only appear to be working when there are multiple staff present. Any idea on how to fix this?
• Formula used in cell G8
=TEXTJOIN(", ",,FILTER(B:B,ISNUMBER(MATCH(A:A,FILTERXML("<m><b>"&SUBSTITUTE(F8&", ",", ","</b><b>")&"</b></m>","//b"),0))))
Or,
• Formula used in cell G3
=ARRAYTOTEXT(FILTER($B:$B,ISNUMBER(MATCH($A:$A,TEXTSPLIT(F3&", ",,", ",1),0)),""))
Try:
Formula in D3:
=TEXTJOIN(", ",,IF(ISNUMBER(XMATCH("*, "&A$3:A$9&", *",", "&C3&", ",2)),B$3:B$9,""))
Note I concatenated leading/trailing comma/space's to prevent possible false positives.
Also, in case you wish to avoid duplicates, just nest UNIQUE() in there:
=TEXTJOIN(", ",,UNIQUE(IF(ISNUMBER(XMATCH("*, "&A$3:A$9&", *",", "&C3&", ",2)),B$3:B$9,"")))

Populating row of dates in cells depending on month picked

I have a sheet where the user is supposed to pick a Month-Name from a dropdown in one cell A2. I want a formula that populates the dates in the row depending on the month picked. Please me in this case.
Thanks in advance.
Perhaps you may try this :
• If you are using MS365 then use
=SEQUENCE(DAY(DATE(YEAR(TODAY()), MONTH(B2 &0)+1, 1) -1),,DATE(YEAR(TODAY()),MONTH(B2&1),1))
• if not then try the one below,
=DATE(YEAR(TODAY()),MONTH(B2&1),ROW(INDIRECT("1:"&DAY(DATE(YEAR(TODAY()),MONTH(B2&0)+1,1)-1))))
Edit: Since OP is using Excel 2013, may try this out:
• Formula used in cell E4
=IF(ROWS(E$4:E4)>DAY(EOMONTH(DATE(YEAR(TODAY()),MONTH($D$4&1),1),0)),
"",DATE(YEAR(TODAY()),MONTH($D$4&1),ROW(A1)))

How to convert a table to a list with row & column header

Is there formala in excel or google spreed sheet can convert a table to a list like this?
from this table:
to this list:
You may try any one of the following approaches, as per your Excel version.
• If you are using Excel 2010/2013/2016/2019/2021/MS365, then this one works for all
Formula used in cell A6
=INDEX($A$2:$A$4,INT((ROW()-6)/COLUMNS($B$1:$D$1))+1)
Formula used in cell B6
=INDEX($B$1:$D$1,MOD((ROW()-6),ROWS($A$2:$A$4))+1)
Formula used in cell C6
=INDEX($B$2:$D$4,MATCH(A6,$A$2:$A$4,0),MATCH(B6,$B$1:$D$1,0))
Note: You may need to change the (ROW()-6) depending on the ROW() from where you are entering the formula for transformation. Example, like if you start from cell or row 3 then it will be (ROW()-3) so on so forth accordingly as per your suit.
• If you are using MS365 and when writing if you have enabled the Office Insiders Beta Channel Version then, using LAMBDA() HSTACK() TEXTSPLIT() DROP() TAKE() TOCOL() & TEXTJOIN() can achieve it as well.
=LAMBDA(array,
HSTACK(TEXTSPLIT(TEXTJOIN(".",1,
DROP(TAKE(array,,1)&"-"&TAKE(array,1),1,1)),"-","."),
TOCOL(DROP(array,1,1))))(A1:D4)
• Also Note : You can use a custom, reusable formula with a friendly name by placing the above formula in the Name Manager - with Define Name as UNPIVOT.
So from Formulas tab, Click on Define Name --> Enter the name as UNPIVOT and place the above formula as in refers to
=LAMBDA(array,
HSTACK(TEXTSPLIT(TEXTJOIN(".",1,
DROP(TAKE(array,,1)&"-"&TAKE(array,1),1,1)),"-","."),
TOCOL(DROP(array,1,1))))
The syntax is
=UNPIVOT(array)
Where array is A1:D4
Closing Note: You can also achieve the above transformation using Power Query as well.

Extract part of text in Excel with condition

I know this questions seems redundant but cannot find an answer. I have a text string such as:
A-B-C-D-E-F
I would like to extract only the first 4 items separated by "-". Result should be
A-B-C-D
Alternatively, I am also looking to extract only the 3rd item:
C
I have been trying the MID and SEARCH functions with no success.
Any help would be well appreciated.
Using TEXTSPLIT (As of this writing only available to Office 365 Insider Beta Channel)
=TEXTJOIN("-",TRUE,INDEX(TEXTSPLIT(A1,"-"),1,{1,2,3,4}))
Change the {1,2,3,4} to 3 for the third.
If one does not have TEXTSPLIT but has TEXTJOIN and is on a PC then:
=TEXTJOIN("-",TRUE,INDEX(FILTERXML("<a><b>"&SUBSTITUTE(A1,"-","</b><b>")&"</b></a>","//b"),1,{1,2,3,4}))
Without TEXTJOIN it will require vba. Like this UDF that mimics TEXTJOIN: MS Excel - Concat with a delimiter
So, this is what I have tried,
• Formula used in cell B1
=TEXTJOIN("-",,TAKE(TEXTSPLIT(A1,"-"),,4))
• Formula used in cell D1
=TEXTJOIN("-",,DROP(TEXTSPLIT(A1,"-"),,-2))
• Formula used in cell C1
=TEXTJOIN("-",,INDEX(TEXTSPLIT(A1,"-"),,3))
Note: Formulas shown above works for O365 Users, Insiders Beta Channel users only!
However, if you have access to Excel 2019, then you can use either TEXTJOIN() or CONCAT()
• Formula used in cell B9
=SUBSTITUTE(CONCAT("-"&INDEX(FILTERXML("<t><s>"&SUBSTITUTE(A9,"-","</s><s>")&"</s></t>","//s"),ROW(A1:A4))),"-","",1)
• Formula used in cell C9
=SUBSTITUTE(CONCAT("-"&INDEX(FILTERXML("<t><s>"&SUBSTITUTE(A9,"-","</s><s>")&"</s></t>","//s"),3)),"-","",1)
Since OP has mentioned in comments, that OP is using O365 in MAC, hence here is an update.
• Formula used in cell B1
=TEXTJOIN("-",,TRIM(MID(SUBSTITUTE(A1,"-",REPT(" ",100)),COLUMN(A1:D1)*99-98,99)))
• Formula used in cell C1
=TRIM(MID(SUBSTITUTE(A1,"-",REPT(" ",100)),COLUMN(C1)*99-98,99))
Or,
• Formula used in cell D1
=TRIM(MID(SUBSTITUTE(A1,"-",REPT(" ",100)),200,100))
For Excel MAC and earlier versions:
Extract first four:
=LEFT(A1,FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),4))-1)
Extract the third:
=MID(A1,FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),2))+1, FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),3))-FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),2))-1)
Easier to understand (now and in the future) if done in small steps.
Assuming source data is in A2:
in B2: =FIND("-",$A2)
in C2: =FIND("-",$A2,B2+1)
in D2, E2: copy across from C2
Then in F2: =LEFT(A2,E2-1)
You can put all of that into one formula, but that's more error-prone.

Return individual cell values from a wildcard search against a range into individual cells using Excel

so I've been trying to work out this problem in Excel (Office 2016, Mac El Capitan, latest updates installed) but have failed so far.
In essence, I would like to search a range of cells (in this case A2:A9) for a partial keyword (A2). Hence all cells that match this criterium should then appear in the result range (E2:E9). I already struggle with this, as I'm only able to return a single result (e.g. one row entry in E2). I have attempted this with INDEX and MATCH but have failed so far.
After this, I would then look-up the corresponding quantity in range B2:B9 using vlookup, this works for now.
The final, desired outcome is attached as an image.
Thanks a lot for your help.
Apply the formula below to E2 and copy down as far as needed.
=IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW(A:A)/ISNUMBER(SEARCH($C$2,A:A)),ROW(A1))),"no more entries")
in F2 use the following formula and copy down as required as well
=SUMIF(A:A,E2,B:B)
A few caveats.
Since the first formula is performing array like calculations inside the aggregate function, full column references should be avoided. Change A:A to $A$2:$A$9or whatever your range is.
Column A is assumed to be full of unique names
The search is not case sensitive. If you need it to be change SEARCH to FIND
If you do not want to see "no more entries" change it to ""
In Cell E2 enter the following formula
=IFERROR(INDEX($A$2:$A$9,SMALL(IF(ISNUMBER(SEARCH($C$2,$A$2:$A$9)),ROW($A$2:$A$9)-1),ROW(1:1))),"")
This is an array formula so commit it by pressing Ctrl+Shift+Enter. Drag/Copy down as required.
Then to get corresponding quantity enter following formula in Cell F2
=INDEX($B$2:$B$9,MATCH(E2,$A$2:$A$9,0))
Drag/Copy down as required. See image for reference.
Note: SEARCH function is case-insensitive. If you are looking for a case sensitive match, use FIND function.

Resources