I am a song leader at our church, and I am using a spreadsheet to track how recently we have used each hymn in our hymnbook. (In an effort to give some rotation to the songs we sing each week.)
Using some very helpful guides on Exceljet, I was able to construct a formula that does almost exactly what I want... It tells me how many weeks ago we used each song in our hymnbook. The problem is that it currently only shows me the FIRST time we used the song, not the LAST or most recent time, which is what I am really wanting to do.
The key issue I am stuck on is how to get the last entry from a MMULT()
formula. A simplified example is shown below... I want to return the last date from column A
where example hymn #15 is listed in columns B
, C
, or D
.
My current formula does a great job of getting the first matching row (Row 3) but does not give me the last row (Row 5).
{=INDEX(ServiceDate,MATCH(1,MMULT(--(HymnNumbers=F2),TRANSPOSE(COLUMN(HymnNumbers)^0)),0))}
( ServiceDate
= A:A
and HymnNumbers
= B:D
)
Yes, I realize that there are other ways to find the last match, with MATCH
and LOOKUP
if I build a very complicated expression that searches for the last match in each column individually and finds the largest date value, but performance is also an issue with the size of the data in the actual spreadsheet I am using.
Is there is something simple that I can tweak in my current MMULT
function to return the last match instead of the first one?
Here's a longer formula that will return the last match. I'm not sure if it fits your definition of "very complicated". This version is longer since it does not use the latest version of excel.
=INDEX(A1:A10,MATCH(LARGE(MMULT(--(B1:D10=F2),TRANSPOSE(COLUMN(B1:D10)^0))*ROW(A1:A10),1),MMULT(--(B1:D10=F2),TRANSPOSE(COLUMN(B1:D10)^0))*ROW(A1:A10),0))
If you have Office365
and dynamic formulas then you can use simply below formula.
=MAX(FILTER(A2:A9,(B2:B9=F2)+(C2:C9=F2)+(D2:D9=F2)))
If you do not have Office365
then try below Array formula.
=MAX(IF(B2:B9=F2,A2:A9,""),IF(C2:C9=F2,A2:A9,""),IF(D2:D9=F2,A2:A9,""))
Press CTRL + SHIFT + ENTER to evaluate the formula as it is an array formula.
Your formula can be amended as follows...
=INDEX(ServiceDate,MATCH(2,1/MMULT(--(HymnNumbers=F2),TRANSPOSE(COLUMN(HymnNumbers))^0)))
However, you can avoid using MMULT as follows...
=INDEX(ServiceDate,LARGE(IF(HymnNumbers=F2,ROW(ServiceDate)-MIN(ROW(ServiceDate))+1),1))
Note that both these formulas need to be confirmed with CONTROL+SHIFT+ENTER.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.