IF ERROR help for a nested IF AVG formula

Options

Hi there! I have an IF followed by AVG formula that is working ok- looks at multiple columns and averages them (frankly it is problematic, because it returns an average even when not all 6 columns are filled out, help? Is there a way for it to only calculate the average once all 6 columns have a value added? Honestly if this part of the problem persists, I think it will still be ok).

When there are no values added to any of those 6 columns, the formula returns the #DIVIDE BY ZERO error. I know I should be able to utilize an IFERROR function at the beginning of my formula to change that error message to either a " " or "Data Needed" return but I'm stuck. This is the current formula:

=IF([SALES HELPER COLUMN]@row = "SALES", AVG([P1 Numeric Score]@row, [P2 Numeric Score]@row, [P3 Numeric Score]@row, [P4 Numeric Score]@row, [P5 Numeric Score]@row, [P6 Numeric Score]@row))

Any thoughts? I'm newer to writing out more complex/nested/multi-function formulas.

Thanks!

Tags:

Answers

  • NickStaffordPM
    NickStaffordPM ✭✭✭✭✭
    Options

    So you could try this, try to make each of those six values part of the intial logical test

    =IF(AND([P1 Numeric Score]@row>1, [P2 Numeric Score]@row >1, [P3 Numeric Score]@row > 1, [P4 Numeric Score]@row >1 , [P5 Numeric Score]@row > 1, [P6 Numeric Score]@row > 1,([SALES HELPER COLUMN]@row = "SALES")), AVG([P1 Numeric Score]@row, [P2 Numeric Score]@row, [P3 Numeric Score]@row, [P4 Numeric Score]@row, [P5 Numeric Score]@row, [P6 Numeric Score]@row),"All Values Not Inputted")

    It essentially is going to look to be sure all those 6 values are greater than 1 (IE not blank) AND that the Sales helper column is = to "SALES". If all values are greater than one and SALES is present, it will average the values, if not, the text "All Values Not Inputted" will populate. To put an if error on the front, you could just do the following:

    =IFERROR(IF(AND([P1 Numeric Score]@row>1, [P2 Numeric Score]@row >1, [P3 Numeric Score]@row > 1, [P4 Numeric Score]@row >1 , [P5 Numeric Score]@row > 1, [P6 Numeric Score]@row > 1,([SALES HELPER COLUMN]@row = "SALES")), AVG([P1 Numeric Score]@row, [P2 Numeric Score]@row, [P3 Numeric Score]@row, [P4 Numeric Score]@row, [P5 Numeric Score]@row, [P6 Numeric Score]@row),"All Values Not Inputted"),"")

    Let me know if this does not help!

    Thanks!

    Nick Stafford

  • SoS | Dan Palenchar
    SoS | Dan Palenchar ✭✭✭✭✭✭
    edited 06/27/24
    Options

    Hello @SoTho,

    You can use this formula

    =IF(AND([Sales Helper]@row = "SALES", COUNT([P1 Numeric Score]@row:[P6 Numeric Score]@row) = 6), AVG([P1 Numeric Score]@row:[P6 Numeric Score]@row))

    Note that this assumes the 6 P# Numeric Score columns are next to each other.

    Here is a published Sheet you can peruse.

    Hope that helps!

    If this helped, help me & the SSC by accepting it and reacting w/💡insightful, ⬆️ Vote Up, and/or ❤️Awesome.

    👨🏼💻 Dan Palenchar | School of Sheets Solutions Consulting | Smartsheet Aligned Gold Partner

    PS - If you have a follow up response use @Dan Palenchar so I get notified of your reply!

    I make YouTube videos answering community questions: see if yours is on the list here!

  • SoTho
    Options

    Thank you so much Dan! My columns are separated but I can adjust and try this!

  • SoTho
    Options

    Thanks also Nick! Excited to try both of these out!

  • SoTho
    Options

    hmmm i had issues with both of these….

    Dan, i got an error about the syntax when i tried to plug yours in and Nick, yours seemed to work but then I noticed that it wasn't populating an average for several rows that DID have all 6 columns filled out.

    Thanks anyways community! I'll keep playing around….

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!