Search code examples
excelexcel-formula

Get the value of the second non-empty cell in a row


0 A B C D E F G H I J K L
1 Product 2023-Saels 2023-Margin 2024-Saels 2024-Margin 2025-Sales 2025-Margin Result
2 Product A 500 30% 150 40% 160 5% 30%
3 Product B 200 10% 900 60% 750 8% 10%
4 Product C 300 19% 400 10% 400 60% 19%
5 Product D 700 50% 930 25% 50%
6 Product E 800 15% 15%
7 Product F 430 32% 32%
8 Product G 360 45% 45%

In Column L I want to display for each product the very first margin per product which is the second non-empty cell in each row.

So far I have been able to develop this formula:

=XLOOKUP(TRUE,ISNUMBER(C2:J2),C2:J2)

It correctly gives me the very first sales which is the first non-empty cell in each row.
How do I need to modify it to display the second non-empty cell in each row?


Solution

  • Likely multiple options. Here's one using BYROW, FILTER, and INDEX:

    =BYROW(C2:J8,LAMBDA(x, INDEX(FILTER(x,ISNUMBER(x)),,2)))
    

    enter image description here