TransWikia.com

IF statement that changes based on met condition

Super User Asked by Berchell on November 26, 2021

Column B is the time in minutes in 1 minute increments. Column I is the time in minutes, but in 1 second increments.

Column C has a list of temperatures. Is there a way to fill Column I with temperatures from Column C that correspond to the correct minute.

The correct results would be once the value in Column I was 1 Column J would be populated with 80 and then once the value in Column I was 2 Column J would be populated with 102.

I wrote the following formula and it works until it gets to 1, but doesn’t work after that. I am not sure how to create an IF statement that changes once a condition is met.

Formula:
=IF(I11=$B$11,$C$11,"")

Any help would be great!

Excel Screenshot

2 Answers

In cell J3 enter the formula =INDEX(C:C,MATCH(INT(I3),B:B,0)) and copy down.

To understand the formula, work inside out:

  1. INT(x) returns minute 1 given minute 1.033
  2. MATCH(INT(x),B:B,0) finds the row in column B in which minute 1 appears
  3. INDEX(C:C,MATCH(INT(x),B:B,0)) picks the temperature in column C corresponding to that row in column B

Answered by bkraines on November 26, 2021

If I understand you properly, this is simply called "nesting."

An IF statement in Excel is =IF(TRUE,DO IF TRUE, DO IF FALSE) and so you simply insert another full IF statement as one of the branches. You can put the IF statement in either (or both) decision branch.

Again, if I have followed your question, you can start with the least likely or last condition, and then nest additional tests in reverse order. It sometimes helps to write it out using notepad or something and then collapse the spacing to fit as a formula (this is pseudocode to hopefully help illustrate the idea better):

=IF(Field = COL3, UseCOL3, 
    IF(Field = COL2, UseCOL2,
        IF(Field = COL1, UseCOL1,
            NoValue
        )
    )
)

Or:

=IF(Field = COL3, UseCOL3,IF(Field = COL2, UseCOL2,IF(Field = COL1, UseCOL1,NoValue)))

It can get "hairy" very quickly.

https://support.microsoft.com/en-us/office/if-function-%E2%80%93-nested-formulas-and-avoiding-pitfalls-0b22ff44-f149-44ba-aeb5-4ef99da241c8

Answered by Yorik on November 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP