SOLVED

Version of Lookup formula?

Copper Contributor

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
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.
best response confirmed by warwick_Hope (Copper Contributor)
Solution

@warwick_Hope 

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

 

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?

@Detlef Lewin
Many thanks!

@Detlef Lewin 

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?)

@warwick_Hope 

That would be:

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

 

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?

Dear @Twifoo,

 

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

 

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!

@warwick_Hope 

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"), "" ) )

@Twifoo 

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

 

1 best response

Accepted Solutions
best response confirmed by warwick_Hope (Copper Contributor)
Solution

@warwick_Hope 

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

 

View solution in original post