Question

I'm wondering if it is possible to extend a SUMIFS formula dependent on an IF statement.

In the example below, what I want is if $O$5 = 0, to extend the SUMIFS formula so that the ">0" becomes criteria1 and then a new criteria_range2 is created, with "<10" as criteria2.

Looking at 'evaluate formula', I'm not sure if the issue is that it won't read the extended bit because it isn't possible to do this, or if the CHAR(34) aren't showing up as I hoped.

=SUMIFS('Revenue'!$G$1:$G$100,'Revenue'!$H$1:$H$100,IF($O$5=0,CHAR(34)&">0"&CHAR(34)&","&"'Revenue'!$H$1:$H$100"&","&CHAR(34)&"<10"&CHAR(34),$O$5))

Any help would be much appreciated! Thanks!

Was it helpful?

Solution

If you'd like to use SUMIFs, it should be something like this:

way №1

=SUMIFS(Revenue!$G$1:$G$100,Revenue!$H$1:$H$100,IF($O$5=0,">0",$O$5),
                            Revenue!$H$1:$H$100,IF($O$5=0,"<10",$O$5)
 )

If O5=0, formula evaluates to:

=SUMIFS(Revenue!$G$1:$G$100,Revenue!$H$1:$H$100,">0",
                            Revenue!$H$1:$H$100,"<10"
 )

If O5<>0, formula evaluates to:

=SUMIFS(Revenue!$G$1:$G$100,Revenue!$H$1:$H$100,$O$5,
                            Revenue!$H$1:$H$100,$O$5
 )

which is actually gives you the same result as

=SUMIFS(Revenue!$G$1:$G$100,Revenue!$H$1:$H$100,$O$5)

way №2

=IF($O$5=0,
  SUMIFs(Revenue!$G$1:$G$100,Revenue!$H$1:$H$100,">0",
                             Revenue!$H$1:$H$100,"<10"),
  SUMIFs(Revenue!$G$1:$G$100,Revenue!$H$1:$H$100,$O$5)
 )

If O5=0, formula evaluates to:

=SUMIFS(Revenue!$G$1:$G$100,Revenue!$H$1:$H$100,">0",
                            Revenue!$H$1:$H$100,"<10"
 )

If O5<>0, formula evaluates to:

=SUMIFS(Revenue!$G$1:$G$100,Revenue!$H$1:$H$100,$O$5)

way №3

Or you can use sumproduct as well:

=SUMPRODUCT((Revenue!$G$1:$G$100)*
            IF($O$5=0,(Revenue!$H$1:$H$100>0)*(Revenue!$H$1:$H$100<10),
                      (Revenue!$H$1:$H$100=$O$5)
            )
 )

This is an array formula, so type the formula then press CTRL+SHIFT+ENTER. Curly brackets will automatically appear at the start and end of the formula.

If O5=0, formula evaluates to:

=SUMPRODUCT((Revenue!$G$1:$G$100)*(Revenue!$H$1:$H$100>0)*
                                  (Revenue!$H$1:$H$100<10)
 )

If O5<>0, formula evaluates to:

=SUMPRODUCT((Revenue!$G$1:$G$100)*(Revenue!$H$1:$H$100=$O$5))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top