Forum Discussion

PeterYac's avatar
PeterYac
Copper Contributor
May 01, 2020
Solved

SUMIFS - Can criteria be entered directly?

Hi,

I have a sumifs like:

 

Sumifs(A1:A4,Z1:Z4,3) where Z1:Z4 contain the number 1,2,3,4

 

I was trying to do this like this:

 

Sumifs (A1:A4,{1,2,3,4},3)  thereby removing the need for the range Z1:Z4.

 

Ideally the I don't want to create the range Z1:Z4 as I don't want the user to see it; i know I can hide or put in on another hidden sheet but if I could get this to work it would be great! 

 

Basically I am trying to sum values based in what quarter it is is so the {1,2,3,4} won't change.

 

Can this - or something similar - be done?

 

thanks

 

Peter

 

 

 

 

  • PeterYac's avatar
    PeterYac
    May 01, 2020

    SergeiBaklan

     

    Hi Sergei,

     

    Thanks for this - your first suggestion works fine.

     

    When I tried SUMIFS(A1:A4,{1,2,3,4},3) I just get a syntax error - Excel clearly does not like {1,2,3,4} in this formula but evaluates it OK in the SUMPRODUCT one. Strange?

    thanks again

     

    Peter

     

     

     

5 Replies

  • JoeUser2004's avatar
    JoeUser2004
    Bronze Contributor

    PeterYac 

     

    You can write:

     

    =SUMPRODUCT(SUMIFS(A1:A4, Z1:Z4, {1,2,3,4}))

     

    That says:  sum A1:A4 where the corresponding row in Z1:Z4 equals 1, 2, 3 or 4.

     

    Is that what you want?

     

    -----

     

    But then you write:  ``I don't want to create the range Z1:Z4 [....] I am trying to sum values based in what quarter it is is so the {1,2,3,4}``

     

    If A1:A4 is the range that you want to sum, there must be another range that indicates the quarter.

     

    But I wonder if that other range does not actually contain the quarter numbers 1, 2, 3 and 4.  Instead, does it contain dates that you __interpret__ as belonging to particular quarters?

     

    Bottom line:  if the SUMPRODUCT(SUMIFS...) formula that I provide above does not work for you, I suggest that you upload an example Excel file that demonstrates the problem to a file-sharing website (e.g. onedrive.live.com), and post the download URL in a response here.

    • PeterYac's avatar
      PeterYac
      Copper Contributor

      Hi Joe

      JoeUser2004 

      Thanks for your response.

      What I was after was:

       

      SUM  A1:A4 where the range Z1:Z4 equals (say) 4; RangeZ1:Z4 holds {1,2,3,4}

      BUT

      instead of using the range Z1:Z4, i would 'hard code' this e.g.

       

      SUMIFS(A1:A4,{1,2,3,4},4)   but this just produces a syntax error and does not appear to like the second parameter .

       

      I think I will go with the SUMPRODUCT but thanks for your feedback!

       

      regards,

       

      Peter

       

       

       

  • SergeiBaklan's avatar
    SergeiBaklan
    Diamond Contributor

    PeterYac 

    I didn't catch entire idea, perhaps that could be done another way, e.g. using CHOOSE(), but if literally when

     

    =SUMPRODUCT(A1:A4*({1;2;3;4}=3))

     

    or

     

    =SUMPRODUCT(A1:A4*(ConstantsList=3))

     

    if you name above array in Name Manager 

    • PeterYac's avatar
      PeterYac
      Copper Contributor

      SergeiBaklan

       

      Hi Sergei,

       

      Thanks for this - your first suggestion works fine.

       

      When I tried SUMIFS(A1:A4,{1,2,3,4},3) I just get a syntax error - Excel clearly does not like {1,2,3,4} in this formula but evaluates it OK in the SUMPRODUCT one. Strange?

      thanks again

       

      Peter

       

       

       

      • SergeiBaklan's avatar
        SergeiBaklan
        Diamond Contributor

        PeterYac 

        Peter, SUMIFS requires the range as argument, SUMPRODUCT works both with ranges and arrays.