Iron Contributor

# IF FORMULA

Dear Experts,

Need your help , So , in a column if I have "1" then print the 1st row of that column, if "0" print nothing, could you please share how to achieve this? also apart from IF , if this can also be used by Index /offset etc too.

Thanks & Regards

Anupam Shrivastava

5 Replies

# Re: IF FORMULA

To achieve the desired result in Excel, where you want to print the first row of a column if the corresponding value in that column is "1" and print nothing if the value is "0," you can use a combination of INDEX, MATCH, and IF functions.

Let us say your data is in columns A to N, and you want to display the result in column O. In cell O1, you can enter the following formula:

=IF(A1=1, INDEX(\$A\$1:\$N\$1, MATCH(1, \$A2:\$N2, 0)), "")

Here is a breakdown of how this formula works:

• IF(A1=1, ... , ""): This part of the formula checks if cell A1 contains the value "1." If it does, it proceeds with the formula; otherwise, it returns an empty string ("") to display nothing.
• INDEX(\$A\$1:\$N\$1, ... ): If the condition is met (A1=1), it uses the INDEX function to extract the values from cells A1 to N1 (the first row of the columns).
• MATCH(1, \$A2:\$N2, 0): The MATCH function is used to find the position (column number) of the first occurrence of "1" in the row containing your data (A2 to N2).

So, this formula checks the value in cell A1. If it's "1," it looks for the corresponding column containing "1" in cells A2 to N2 and displays the value from the first row of that column. If A1 is not "1," it displays nothing ("").

You can then drag this formula down in column O to apply it to the entire dataset.

This approach uses INDEX, MATCH, and IF functions to conditionally retrieve and display the data based on the presence of "1" or "0" in the first row of each column. The text, steps and functions were created with the help of AI.

My answers are voluntary and without guarantee!

This will help all forum participants.

# Re: IF FORMULA

This will do it:

``````=LET(
matrix, (rgb = 1) * SEQUENCE(, cols),
IF(element > 0, INDEX(header, , element), "")
),
)``````

# Re: IF FORMULA

Hi@NikolinoDE , seems need to Modify it a bit.. it populates only w.r.t Cell A1

Br,

Anupam

# Re: IF FORMULA

``=IF(A2=1,A\$1,"")``

This formula could be a very simple alternative. The formula is in cell O2 and filled across range O2:AB17817.

# Re: IF FORMULA

``=MAKEARRAY(ROWS(A2:G9),COLUMNS(A2:G9),LAMBDA(r,c,IF(INDEX(A2:G9,r,c)=1,INDEX(A1:G1,,c),"")))``

An alternative with Office 365 or Excel for the web could be this formula.