Using CONTAINS for 2 criteria

PSames
PSames ✭✭✭

I am having a problem creating a formula using contains for 2 criteria. Here is my formula that pulls the information I need.

=SUMIFS([Column2]1:[Column2]22, [Primary Column]1:[Primary Column]22, CONTAINS("hat", @cell))

I want to sum column 2 if the primary column contains "hat" and "gloves". I get various errors when I try to add "gloves". Can contain be used for 2 different criteria?

Additional question - can you use CONTAIN with <> so it returns only entries that does not have that text string in column?

Thanks for any help with this.

Best Answer

  • PSames
    PSames ✭✭✭
    Answer βœ“

    Genevieve and Paul,

    Thank you for all of your help with this. I was able to get the formula to work with using SUM with the SUMIFS. Here is the formula I used to total all rows that had either hats or gloves in the primary column.

    =SUM(SUMIFS([Column2]1:[Column2]24, [Primary Column]1:[Primary Column]24, CONTAINS("hat", @cell)), SUMIFS([Column2]1:[Column2]24, [Primary Column]1:[Primary Column]24, CONTAINS("gloves", @cell)))

    Then to exclude certain colors here is the formula that worked.

    =SUM([Column2]1:[Column2]24, -(SUM(SUMIFS([Column2]1:[Column2]24, [Primary Column]1:[Primary Column]24, CONTAINS("blue", @cell)), SUMIFS([Column2]1:[Column2]24, [Primary Column]1:[Primary Column]24, CONTAINS("green", @cell)))))

    I appreciate your explanation and will go back and use your suggestions to shorten the formulas.

    This community is awesome. Although I do not post many questions I use the search function to find answers regularly.

    Hope you have a great day!

    Patty

Answers

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!