Friday, February 11, 2011

Use of array formulae

Using array formulas can give you power to do what you can't do in normal sumif or sum formulas:

here is an examples

Consider the following list

AgeSexDepositPROFILE
23M500JOB
23F600BUS
24M600CONSULTANT
25F600JOB
24M600BUS
24F600CONSULTANT
23M800JOB
23M800BUS
24F800CONSULTANT
23M800JOB
24F800BUS
23F400CONSULTANT
24F400JOB
23M400BUS


Suppose you want to find out total deposit of people with age of 23, Female in business.

One way is to create a pivot and you can get the result but in that case you need to refresh again and again in case you change the data.

If you don't want to use pivot, array formulas come to your resort.

Have a look at following formulae

{=SUM(($A$2:$A$15=23)*($B$2:$B$15="F")*($D$2:$D$15="BUS")*C2:C15)} gives the result as 600

You must be wondering what curly bracket doing here. actually this the way excel recognise it as an array formulae and calculate it accordingly. For this you need to press cntl shift enter while entering the formulae instead of enter as you do in normal formulae.

Now let's try to understand how it works.

One can easily understand the criteria given in brackets like we are checking age 23 in column A, text F in column B etc.

What is different here is symbol * that is inserted between two brackets. This is used like an "and" argument between two criteria. Thus we are saying range $A$2:$A$15=23 and range $B$2:$B$15="F and $D$2:$D$15="BUS and sum range is C2:C15. This is similar to what we do while applying filter when we have more then one conditions.

similarly for OR argument we can use +

Trust me, it can be a powerful technique if you can use it efficiently