+ Reply to Thread
Results 1 to 9 of 9

cannot exclude a cell when using AVERAGEIF

  1. #1
    Registered User
    Join Date
    11-30-2020
    Location
    coventry, england
    MS-Off Ver
    2019
    Posts
    10

    cannot exclude a cell when using AVERAGEIF

    I have the following range where some cells are either blank or contain zero. However there is one cell that contains a number generated by a formula. However despite formatting that cell as 'text' , the AVERAGEIF function still sees it as a number.

    For the range below, the cell containing the number 2 which is has been generated from another formula i.e. =A1/C1 is still seen by the AVERAGE OR AVERAGEIF formula even if i have formatted this cell as 'text'.


    F1:1, F2:2,F3:0,F4:0, F5:0 = average

    The formula i have previously used was AVERAGEIF(F1:F5,"<>0") which excluded the cells containing zero. The average for this range should be 1 if cells F2 to F5 had been excluded.


    If formatting cell F2 as Text does not exclude the value in this cell, how can i adjust the AVERAGEIF formula to achieve this?

    I would have inserted an image but for some reason this option doesnt appear to be working.

    Thanks

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,894

    Re: cannot exclude a cell when using AVERAGEIF

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    11-30-2020
    Location
    coventry, england
    MS-Off Ver
    2019
    Posts
    10

    Re: cannot exclude a cell when using AVERAGEIF

    I didnt want to attach a sample workbook. It was an image i wanted to insert within the body of the text field

  4. #4
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: cannot exclude a cell when using AVERAGEIF

    Formatting as Text after initial population won't change the underlying value (just the presentation), recommitting the formula will enforce the underlying value becomes Text.

    i.e. if you re-commit the formula in F2 then =AVERAGEIF(F1:F5,"<>0") should return 1

    edit: sorry -- my bad, rather than format as text, use =< calc >&"" to force to string (leaving as General/Number)

    Note: some other calcs like COUNTIF for ex. will still treat the literal text as a number depending on use case

    =COUNTIF(F1:F5,2) will return 1 even though the criteria is number, and the value in the range is "2"

    if you put a numeric clause in - the "2" will be ignored

    =COUNTIFS(F1:F5,2,F1:F5,">-9.99E+307")
    Last edited by XLent; 01-27-2021 at 04:59 AM.

  5. #5
    Registered User
    Join Date
    11-30-2020
    Location
    coventry, england
    MS-Off Ver
    2019
    Posts
    10

    Re: cannot exclude a cell when using AVERAGEIF

    Not sure I understand what you mean by 'if you re-commit the formula in F2'

    can you please clarify?
    thanks

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,894

    Re: cannot exclude a cell when using AVERAGEIF

    Quote Originally Posted by surfing96 View Post
    I didnt want to attach a sample workbook. It was an image i wanted to insert within the body of the text field
    Images are of little value, which is why we ask for sample workbooks instead. Besides, NOBODY should have to retype your data to be able to test a solution for you.

  7. #7
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: cannot exclude a cell when using AVERAGEIF

    Hi, do following on blank tab

    F1: =1
    E2: =2
    F2: =E2&""
    F3: =0
    F4: =0
    F5: =0
    F6: =AVERAGEIF(F1:F5,"<>0")

    you should find you get an answer of 1.

    my point was, if F2 was set to =E2 but subsequently format as Text, the above would return 1.5 as the underlying value would be seen as number.
    (re-committing the formula wouldn't work here, with cell format as Text, as it would simply return "=E2" as a literal, hence the &"" approach in E2 formula, which will coerce to string)

  8. #8
    Registered User
    Join Date
    11-30-2020
    Location
    coventry, england
    MS-Off Ver
    2019
    Posts
    10

    Re: cannot exclude a cell when using AVERAGEIF

    if this is the case, why do you have the option to insert an image. If it serves no value why dont you just get rid of it.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,894

    Re: cannot exclude a cell when using AVERAGEIF

    LOL! Well, we'd love it to work, but actually it would lead to the same dialog as the instructions at the top, allowing various types of attachment. An image is only ever really of any use if the OP and their helpers are seeing different behaviour in the same workbook. The paper clip has been broken for years - we can't get the owner and his tech team to fix it (they don't seem to care), which is embarrassing for us.

    However, you are missing the point a bit: generally speaking, a workbook is MUCH more helpful than an image, for the reasons I outlined above, so please use that option in future. And please don't take offence when you are asked to do something a bit differently to what you expect - it's for YOUR benefit in the long run.
    Last edited by AliGW; 01-27-2021 at 06:20 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Averageif for a range matching to a cell
    By ReinAD88 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-24-2019, 04:15 AM
  2. Add EXCLUDE Option in table to Exclude from Solver
    By lbofbb in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-17-2015, 09:05 AM
  3. EXCEL 2003 - Need an "AVERAGEIF" formula to exclude "0" in average
    By kerry0507 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-18-2015, 03:37 PM
  4. Averageif WILDCARD for website.com AND EXCLUDE website.com.xx
    By Gerhard.Angeles in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-14-2014, 09:12 AM
  5. AverageIF with conditions and excludes value if adjacent cell is blank
    By dbaker4020 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-31-2013, 12:41 PM
  6. [SOLVED] AVERAGEIF if an adjacent cell falls within a certain RANGE
    By jesilva82 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-31-2013, 11:52 AM
  7. Replies: 2
    Last Post: 08-30-2012, 09:25 AM

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