Forum Discussion

grantwilliams275's avatar
grantwilliams275
Copper Contributor
Oct 24, 2025
Solved

Excel formula help - vertical and horizontal in same calculation

Hello,

I have a set of data that contains resource names and their FTE effort per month. I'm trying to calculate their start month and end month in two cells but can't get my head around the correct formula. Here is an an example data set:

 ACDEFGHIJKLNOP
1IDEmployeeStart MonthEnd MonthM1M2M3M4M5M6M7M8M9M10M11M12
21John????00011110.50.5000
32Brian????11110.50.5000000
43Alison????0000000.50.51111

 

The result I'm looking for is for John - Start M4, End M9; Brian - start M1, End M6; Alison - start M7, End M12 .. i.e. its linked to non-zero cells

I have a formula using match/index that I found on the web that is getting the start date (example of John's row):

=INDEX('!E$1:P$1, MATCH(TRUE, '!E2:P2<>0,0))

I can't however amend that formula to work for the end date. I'm more familiar with XLOOKUP than MATCH/INDEX and I'm assuming there is some embedded XLOOKUP (=XLOOKUP("1", A:A, XLOOKUP("<>0", <<second row>>, <<first row>>) - cant get this to work ,  that could work here, but its outside the limits of my abilities.

Suggestions please?

  • As variant

    Start 

    =XLOOKUP(2,1/(E2:P2<>0),$E$1:$P$1,,-1)

    End

    =LOOKUP(2, 1/(E2:P2<>0), $E$1:$P$1)

     

4 Replies

  • thank you both - that works for me now! Off to audit the 3000 lines of data for accuracy...

  • SergeiBaklan's avatar
    SergeiBaklan
    Diamond Contributor

    Another alternative for Start

    =TAKE(FILTER($E$1:$P$1,E2:P2),,1)

    for End

    =TAKE(FILTER($E$1:$P$1,E2:P2),,-1)

    For the spill of both

    =TAKE(FILTER($E$1:$P$1,E2:P2),,{1,-1})

    (similar with XLOOKUP)

  • SergeiBaklan's avatar
    SergeiBaklan
    Diamond Contributor

    As variant

    Start 

    =XLOOKUP(2,1/(E2:P2<>0),$E$1:$P$1,,-1)

    End

    =LOOKUP(2, 1/(E2:P2<>0), $E$1:$P$1)

     

Resources