• 662K Members
• 5,323 Online
• 813K Conversations
SOLVED

Highlighted
New Contributor

# Version of Lookup formula?

Have a table dates across the top and items down the side.

The body of the table gets populated with "1s" which auto formats to a cell colour.

Id like to create a column that looks up when a row has a "1" in and then returns the date in the column header.

Just struggling to find what sort of formula to use for it any guidance would be appriciated

11 Replies
Highlighted

# Re: Version of Lookup formula?

I suppose you want to return the date IF the cell contains 1; otherwise, you want to return empty text. I hope you now know what formula to use.
Highlighted
Solution

# Re: Version of Lookup formula?

`=LOOKUP(PI(),B2:Z2,B\$1:Z\$1)`

Highlighted

# Re: Version of Lookup formula?

I had tried using "IF" but the "1" could be in any cell across the table, and i didnt want to have to create a long formula with 20 "IF" Logical tests!
Is there a shorter way of achieving the same thing?

Highlighted

@Detlef Lewin
Many thanks!
Highlighted

# Re: Version of Lookup formula?

If there is more than one cell filled in a row, the formula picks up the cell furthest to the right.

This is fine in the main but just wanted to know if there was any way of changing it to pick the first cell it comes to? (furthest to the left?)

Highlighted

# Re: Version of Lookup formula?

That would be:

`=INDEX(B\$1:Z\$1,MATCH(1,B2:Z2,0))`

Highlighted

# Re: Version of Lookup formula?

I’m just curious. What would be the equivalent formula to achieve the same result using LOOKUP and OUR sexy PI() as the lookup_value argument?
Highlighted

# Re: Version of Lookup formula?

Dear @Twifoo,

I have no idea. The problem is that LOOKUP() works from right to left.

Highlighted

# Re: Version of Lookup formula?

Hello @Detlef Lewin,
Just to satisfy my curiosity, this is the equivalent of the INDEX-MATCH formula using LOOKUP-PI.
=LOOKUP(PI(),
2/(1/COLUMN(B2:Z2)=AGGREGATE(14,4,1/COLUMN(B2:Z2)*((B2:Z2)=1),1)),
B1:Z1)
Indubitably, INDEX-MATCH formula is preferred but the foregoing formula satisfied my curiosity!
Highlighted

# Re: Version of Lookup formula?

When dynamic arrays are released, multiple matches will be returned by

= FILTER( Date, Criterion )

To do something similar now would need

= SMALL( IF( Criterion, Date ), {1,2,3} )

The dates could also be listed in a wrapped cell using

= TEXTJOIN( CHAR(10), TRUE, IF( Criterion, TEXT(Date,"dd mmm"), "" ) )

Highlighted

# Re: Version of Lookup formula?

I expected that a possible solution would be considerably longer and more complex.