Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Formula to Get nth to Last in Comma Separated List

I have a column with cells that contain months separated with commas. I need to return the nth from last month.

Example dataset:

Months Nth from Last Result
2024 May, 2023 October, 2023 May 2 2023 October
2023 October, 2023 August, 2023 May, 2023 January 3 2023 August
2024 March, 2024 February 2 2024 March

So based on the Months column I want to return the nth value (defined in the Nth from Last column) on the Result column. Note, this is looking from oldest to newest with the cells organized from newest to oldest. This will always be the case.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You may try:

=map(A2:A,lambda(Σ,if(Σ="",,choosecols(split(Σ,", ",),-offset(Σ,,1)))))

enter image description here

If you just want a single-cell formula, it would be:

=choosecols(split(A2,", ",),-B2)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading