How can I use COUNTIF to count rows?

I am linking a report with another spreadsheet and each row in the spreadsheet is labeled either Facebook or Google. In my report, I need the total number of rows for Facebook or Google in order to figure out other calculations for my social media report. I have tried using:

=COUNTIF({Social Media Data 2021 Range 8}, CONTAINS("facebook"))

This comes back as #INVAID OPERATION.

The way I normally see the COUNTIF function used is to collect data from column A if criteria is met in column B , but I just need a total number of rows. Any suggestions on how to accomplish this?

Answers

  • Nic Larsen
    Nic Larsen ✭✭✭✭✭✭
    edited 07/08/21

    Try this

    =COUNTIF({Social Media Data 2021 Range 8}, CONTAINS("facebook", @cell))


    Updated - had my " in the wrong spots.

  • Cindi Meche
    Cindi Meche ✭✭✭

    Hi Nic. I tried that and even checked the criteria, but it's not working. Still says #INVALID OPPERATION.

    =COUNTIF({Social Media Data 2021 Range 8}, CONTAINS("Facebook, @cell"))

    Should the @cell count the cells (therefore rows)?

  • Nic Larsen
    Nic Larsen ✭✭✭✭✭✭

    Be sure to use the revised formula one I put in there. I had my quotes around @ cell rather than around facebook when I first submitted.

    =COUNTIF({Social Media Data 2021 Range 8}, CONTAINS("facebook", @cell))

    Is your range a single column? If so, this worked fine for me when I tried it.

    You can also run it this way - depending on if there is other data in the cell other than facebook/google:

    =COUNTIF({Social Media Data 2021 Range 8}, "facebook"

  • Cindi Meche
    Cindi Meche ✭✭✭

    That's it! It worked! Thank you so much for your help.

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!