Formulas and Functions

Formulas and Functions

Ask for help with your formula and find examples of how others use formulas and functions to solve a similar problem.

Formula for countifs and or from multiple columns

✭✭✭
edited 07/26/24 in Formulas and Functions

Hello,

I am trying to count if {Goal #1} and {Goal #2} are not blank IF {Office Name} is [Primary Column]@row OR {Division Name] is [Primary Column]@row.

The way my tracker sheet is set up is that I have Office Name & Division Name as separate columns and I need to count that each office or division has completed Goal #1 and Goal #2 (anything can be in the field.)

I'd like to use one formula for the whole metrics page for ease, so below is what I have now and it seems to be working, but I'm curious if there's a simpler way to either set up my tracker or write the formula.

=SUM((COUNTIFS({Division Name}, [Primary Column]@row, {Goal #1}, <>"")) + (COUNTIFS({Division Name}, [Primary Column]@row, {Goal #2}, <>"")) + (COUNTIFS({Office Name}, [Primary Column]@row, {Goal #1}, <>"")) + (COUNTIFS({Office Name}, [Primary Column]@row, {Goal #2}, <>"")))

Thanks!

Best Answer

  • Community Champion
    Answer ✓

    Your current formula is adding the number of rows where

    the division name matches the primary column and goal one has a value

    plus the number where the division matches and goal two has a value

    plus the number where the office matches and goal one has a value

    plus the number where the office matches has goal two has a value.

    It is not checking that the division or office has both goal 1 AND goal 2. So depending on your data might, it not be working. If both goals are specified your total will be 2. If only 1 is specified the total will be 1. If the same division or office has a second row with the same goal in, the total will also be 2.

    An alternative, and simpler, formula is.

    =(COUNTIFS({Division Name}, [Primary Column]@row, {Goal #1}, <>"", {Goal #2}, <>""))

    + (COUNTIFS({Office Name}, [Primary Column]@row, {Goal #1}, <>"", {Goal #2}, <>""))

    Just be aware, it is not doing exactly what your formula is. This one is counting only the rows where the division name matches the value in the primary column and goal 1 is not blank and goal 2 is not blank. All three things must be true to return a one. It then does the same for Office Name and adds those two counts together.

    Hope that helps.

Answers

  • Community Champion
    Answer ✓

    Your current formula is adding the number of rows where

    the division name matches the primary column and goal one has a value

    plus the number where the division matches and goal two has a value

    plus the number where the office matches and goal one has a value

    plus the number where the office matches has goal two has a value.

    It is not checking that the division or office has both goal 1 AND goal 2. So depending on your data might, it not be working. If both goals are specified your total will be 2. If only 1 is specified the total will be 1. If the same division or office has a second row with the same goal in, the total will also be 2.

    An alternative, and simpler, formula is.

    =(COUNTIFS({Division Name}, [Primary Column]@row, {Goal #1}, <>"", {Goal #2}, <>""))

    + (COUNTIFS({Office Name}, [Primary Column]@row, {Goal #1}, <>"", {Goal #2}, <>""))

    Just be aware, it is not doing exactly what your formula is. This one is counting only the rows where the division name matches the value in the primary column and goal 1 is not blank and goal 2 is not blank. All three things must be true to return a one. It then does the same for Office Name and adds those two counts together.

    Hope that helps.

  • ✭✭✭

    Thank you! This is helpful. Used this formula with symbols so we can quickly see who is "complete" :)

  • Community Champion

    Wonderful! Thanks for letting me know.

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!

Trending in Formulas and Functions

  • I'm trying to create a SUMIF formula that looks at the salesperson name in a column and adds up or totals their $ sales in another column. To ultimately show in Dashboard of Totals Sales by Salesperso…
    User: "Allan Z"
    Answered ✓
    9
    2
  • Good day Smartsheet Team, Getting an unparseable error on this formula: =IF($Name@row <> "",(SUMIFS({Expense}, {Period},1, {Type}, OR(@cell = "RES602782", @cell = "RES602497")),"") Trying to pull in a…
    User: "stratman"
    Answered ✓
    15
    2
  • I have a sheet that compiles all the responses from a form. The sheet has multiple start and end date columns, but only one start and one end date cell is NOT blank depending on the activity selected …
    User: "m_anderson"
    Answered ✓
    13
    2