IF Statement Pain Scores

%3CLINGO-SUB%20id%3D%22lingo-sub-2643711%22%20slang%3D%22en-US%22%3EIF%20Statement%20Pain%20Scores%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2643711%22%20slang%3D%22en-US%22%3E%3CP%3EHI%20All%20-%20I%20am%20trying%20to%20write%20an%20IF%20Statement%20for%20the%20following%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20two%20columns%20of%20numbers%20(very%20long%20columns).%3C%2FP%3E%3CP%3EThe%20first%20list%20is%20numbers%20from%207-10%20(A2)%20%2C%20the%20second%20list%20is%20numbers%20from%200-10%20(B2).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20to%20identify%20(count)%20the%20rows%20where%20the%20second%20column%20has%20a%20number%20at%20least%202%20or%20more%20lower%20than%20the%20first%20column.%20The%20outcome%20would%20be%20all%20of%20the%20highlighted%20numbers%20below.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20you%20help%20me%20write%20the%20formula%20to%20achieve%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Mel_from_the_Territory_0-1628827517920.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F302910i70421F62AD8A647F%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Mel_from_the_Territory_0-1628827517920.png%22%20alt%3D%22Mel_from_the_Territory_0-1628827517920.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2643711%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2643960%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Statement%20Pain%20Scores%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2643960%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1127398%22%20target%3D%22_blank%22%3E%40Mel_from_the_Territory%3C%2FA%3E%26nbsp%3BFirst%20of%20all%2C%20your%20%22numbers%22%20are%20in%20fact%20texts%20(except%20for%20cell%20B2%2C%20that%20seems%20to%20contain%20the%20real%20number%2010)%20and%20it's%20difficult%20to%20calculate%20with%20texts.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EStart%20by%20selecting%20column%20B.%20On%20the%20Data%20ribbon%2C%20select%20Text-to-columns%20and%20press%20Finish.%20Repeat%20for%20column%20C.%20That%20should%20have%20transformed%20the%20texts%20to%20numbers%20and%20the%20small%20green%20triangles%20should%20be%20gone%20now.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20regard%20to%20the%20formula%20needed%20for%20the%20highlights%20in%20the%20screenshot%3CSPAN%3E%26nbsp%3Byou%20could%20use%20conditional%20formatting%20with%20a%20rule%20(based%20on%20a%20formula)%20like%3A%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%3DC2%26gt%3B%3DB2-2%3C%2FSTRONG%3E%2C%20applied%20to%20the%20range%20starting%20in%20C2%20all%20the%20way%20down.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%2C%20if%20you%20prefer%20a%20formula%20in%20a%20separate%20column%20you%20could%20enter%20%3CSTRONG%3E%3DIF(C2%26gt%3B%3D%20B2-2%2C%20%22x%22%2C%22%22)%20%3C%2FSTRONG%3Ein%20an%20empty%20column%20on%20row%202%20and%20copy%20it%20all%20the%20way%20down.%20An%20x%20would%20mark%20the%20rows%20that%20meet%20the%20criteria.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2644525%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Statement%20Pain%20Scores%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2644525%22%20slang%3D%22en-US%22%3EOh%20thank%20you!%20Such%20an%20obvious%20error%20on%20my%20part%20to%20start%20with%20that%20I%20couldn't%20see%20for%20looking!%3CBR%20%2F%3EYour%20answer%20Riny%20has%20worked%20perfectly%2C%20thank%20you%20so%20very%20much!%20Stay%20COVID%20Safe%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FLINGO-BODY%3E
New Contributor

HI All - I am trying to write an IF Statement for the following

 

I have two columns of numbers (very long columns).

The first list is numbers from 7-10 (A2) , the second list is numbers from 0-10 (B2).

 

I need to identify (count) the rows where the second column has a number at least 2 or more lower than the first column. The outcome would be all of the highlighted numbers below.

 

Can you help me write the formula to achieve this?

 

Mel_from_the_Territory_0-1628827517920.png

 

3 Replies

@Mel_from_the_Territory First of all, your "numbers" are in fact texts (except for cell B2, that seems to contain the real number 10) and it's difficult to calculate with texts.

 

Start by selecting column B. On the Data ribbon, select Text-to-columns and press Finish. Repeat for column C. That should have transformed the texts to numbers and the small green triangles should be gone now.

 

With regard to the formula needed for the highlights in the screenshot you could use conditional formatting with a rule (based on a formula) like: =C2>=B2-2, applied to the range starting in C2 all the way down.

 

Or, if you prefer a formula in a separate column you could enter =IF(C2>= B2-2, "x","") in an empty column on row 2 and copy it all the way down. An x would mark the rows that meet the criteria.

Oh thank you! Such an obvious error on my part to start with that I couldn't see for looking!
Your answer Riny has worked perfectly, thank you so very much! Stay COVID Safe

@Mel_from_the_Territory 

My formula for conditional formatting would be

=(@FirstPain-@LastPain)<=2

but I have forgotten what that would look like pre-365.  Of further interest you also mention 'count' along with 'identify'.   A count could be obtained from

= COUNT(IF((FirstPain-LastPain)<=2,1))

Using 365 a list of the highlighted rows could be returned by

= LET(
  criterion, (FirstPain-LastPain)<=2,
  FILTER(ID, criterion))

(a similar formula would apply with legacy Excel.

image.png