Forum Discussion

anncshaw's avatar
anncshaw
Copper Contributor
Jun 26, 2021

Using and IF/And to add to an array formula to count

Hi use the following formula to sum Purchase Orders in my file.   I would like to add in and if or if and or some other part so that the formula will also count by location which is in column C.

There are various sites so maybe every time the site name changes then count the number of sites?

=sum(1/(countif(a3069:a6059,a3069:a60529)))}

Many thanks

Ann

7 Replies

  • Yea_So's avatar
    Yea_So
    Bronze Contributor

    Hi anncshaw,

    You provided:

    Hi use the following formula to sum Purchase Orders in my file.   

    Does the sum involve the number of how many Purchase Orders you have, or the sum of the Purchase Order amounts?

     

    I would like to add in and if or if and or some other part so that the formula will also count by location which is in column C.

    How many locations? and what are they? Cities? States? Regions?

    There are various sites so maybe every time the site name changes then count the number of sites?

    Are these sites locations? or websites?

    =sum(1/(countif(a3069:a6059,a3069:a60529)))}

    In the sum function you are using, what does the 1 represent?

    In the countif function you are using, what is the criterion/criteria?

    Return value 
    A number representing cells counted.
    Syntax 
    =COUNTIF (range, criteria)
    Arguments 
    range - The range of cells to count.
    criteria - The criteria that controls which cells should be counted.

    example: =COUNTIF(a3069:a6059,"New York")

     

    Your narrative is somewhat ambiguous and cryptic.  Can you please elaborate? or maybe share an anonymized (no private info) version of your workbook, because that would be helpful to us and be able to help you with a solution.

     

    cheers

     

     

    • anncshaw's avatar
      anncshaw
      Copper Contributor

      HiYea_So 

       

      The formula is as follows:

       

      {=SUM(1/(COUNTIF(A2:A121,A2:A121)))}

      This counts the number of POs for year 2016 then in the next row the same formula but different range to count the number of POs for year 2017 etc

      {=SUM(1/(COUNTIF(A122:A1233,A122:A1233)))}

      {=SUM(1/(COUNTIF(A1234:A3068,A1234:A3068)))}

      342016 EES PO's
      3572017 EES PO's
      5122018 EES PO's
      9582019 EES PO's
      13922020 EES PO's
      6642021 EES PO's

      First column contains that formula for the count.

       

      The sites refer to Departments and there are two but I need to include them in my formula to include the count if the site is one department and then if it is the other department. These are in column C in my sheet with the following data:

      ALEXIS FARMA INT
      ALEXIS DUBLIN
      ALEXIS FARMA INT
      ALEXIS DUBLIN
      ALEXIS FARMA INT
      ALEXIS DUBLIN

       

      So I need the count included for each of these departments.

      I hope this makes sense.

       

      Many thanks

      Ann

       

      • JMB17's avatar
        JMB17
        Bronze Contributor
        Try this. Of course, you could use a cell reference for the department.

        =SUM((C2:C121="ALEXIS FARMA INT")/COUNTIFS(A2:A121,A2:A121,C2:C121,C2:C121))

Resources