CountIf formula within MS Access report

61,507

Solution 1

There is no Countif function in Access. However, you can use Sum and IIf (ie, Immediate If) to accomplish the same thing. Try:

=Sum(IIf([Service] Like "*Housing*", 1, 0))

The above assumes you want the Service column to contain the word "Housing". This assumes you were being precise in the wording of your question. If you really meant that you want to count the number of records where the Service column equals "Housing" exactly, you would use this instead:

=Sum(IIf([Service] = "Housing", 1, 0))

Solution 2

This also works:

=Count(IIf([Service]="Housing",1))
Share:
61,507
Kris
Author by

Kris

Updated on August 04, 2022

Comments

  • Kris
    Kris almost 2 years

    Something terrible as happened with my poor attempt at adding a CountIf forumula to my access report.

    I am trying to add a formula within my report header to count the number of entries in my Service column that contain a certain word. The problem is I am an absolute amateur when it comes to SQL code.

    =CountIf([Service]="Housing")
    

    Is the code I was hoping would work but I don't seem to be getting anywhere.