+ Reply to Thread
Results 1 to 8 of 8

Logical test for integer or non- integer

  1. #1
    Registered User
    Join Date
    08-01-2011
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Logical test for integer or non- integer

    I am trying to calculate the relative percent difference (rpd) between the values in two cells where one or both the values may be input as "<0.1" (as an example). The rpd formula is:

    =ABS(x-y/((x+y)/2))

    Where the data values could be any of the following four formats:

    x , y
    1 , 2
    1 , <0.2
    <0.2 , 2
    <0.1 , <0.1

    If both values are in the "<0.1" format I need "BBL" to be displayed, If one is "<0.1" I need the formula to see that cell as "0.1" (I can have another cell with "0.1" that it can reference).

    I think all I need is a nested IF statement where the logical test decides if each cell is an integer or not.

    Closest I've got (which doesn't work) is:

    =IF((AND(A1>0,B1>0)),ABS((A1-B1)/((A1+B1)),IF(A1<0,ABS((C1-B1)/((C1+B1)/2)),IF(B1>0,ABS((A1-C1)/((A1+C1)/2)),(IF((AND(A1<0,B1<0)),BBL,"Error")))))

    Where C1 is "0.1"

    Any help would be awesome!
    Last edited by MHRW; 08-04-2011 at 12:51 AM.

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Logical test for integer or non- integer

    Perhaps a formula like this?

    =IF(AND(A1<0.1,B1<0.1),"BBL",IF(AND(A1<0.1,B1>0.1),ABS($C$1-B1/(($C$1+B1)/2)),IF(AND(A1>0.1,B1<0.1),ABS(A1-$C$1/((A1+$C$1)/2)),ABS(A1-B1/((A1+B1)/2)))))

    This formula assumes that you have the value 0.1 in cell C1.

    Question: If both A1 and B1 is equal to 0.1 do you have a special case fore that?

    If you want to test for integre one way would be to use the MOD function i.e =MOD(A1,1)
    will always return zero if A1 = 1, 2, 3 and so forth. If A1 = 1.19 or 0.19 then the MOD(A1,1) function will return the value 0.19

    Alf
    Last edited by Alf; 08-02-2011 at 01:43 PM. Reason: Change of delimeter in formula

  3. #3
    Registered User
    Join Date
    08-01-2011
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Logical test for integer or non- integer

    Thanks Alf, Its still getting stuck at the same point though. I've attached a spreadsheet with an example of the data i'm trying to work with. The table on the right is how I want it to look (I've manually put in the formula / value for each line).

    I appreciate the help!
    Attached Files Attached Files

  4. #4
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Logical test for integer or non- integer

    Hi,

    How about:

    Please Login or Register  to view this content.
    Cheers,
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  5. #5
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Logical test for integer or non- integer

    Its still getting stuck at the same point though.
    That's not strange as the formula I gave you is supposed to work only with numbers.
    In the workbook you posted you try to use the formula on a mixture of strings and numbers.

    ConnecXionLost:
    Not to happy about you jumping into this tread before I got a chance to answer but I must confess your solution (ISNUMBER) was better than mine (testing for "<") so I guess this is a case of "may the best man win".

    MHRW beware that values in F column (Detection Limits) must be numbers as they will be used in calculation if C or D values are strings.

    Alf

  6. #6
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Logical test for integer or non- integer

    ConnecXionLost:
    Not to happy about you jumping into this tread before I got a chance to answer
    Hi Alf,

    please keep in mind that every member can answer threads at any moment, no one never stated that the first one to answer has priority over others.

    Suppose you went on vacation or your computer crashed badly. Is the OP obliged to wait for you to come back to get an answer???

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Logical test for integer or non- integer

    Suppose you went on vacation or your computer crashed badly
    Then I would not be back that quick to grumble. Yes the OPs must be kept happy by getting a fast and correct answer but what about the forum members who provide the answers? They must be kept happy as well or the forum will die.

    Since this is the “Excel General” forum I’ll start a new tread in “The Water Cooler” forum and air a few of my questions and views linking to this thread.

    Alf

  8. #8
    Registered User
    Join Date
    08-01-2011
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Logical test for integer or non- integer

    Thanks ConnecXionLost and Alf,

    ISNUMBER works a treat! exactly what I was after

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1