A minor mistake in my previous post
What are Array Functions or Array Formulas
Function SumSQ()
Function RandBetween()
Function Rand()
Function Odd()
Function Sign()
Function SQRT()
Function Value()
Function Trim()
Function Substitute()
Function Search()
Function Mid()
Function Len()
Function Find()
Function Exact()
Function Concatenate()
Wednesday, June 24, 2009
Usage of Array Functions
- Calculating average of a series based on multiple conditions, where the conditions are applicable on mupltiple data columns
- Calculating count of a column with one or more conditions applicable on column other than the one on which count is to be performed
- The most importance advantage of array functions, especially over functions like SumIF(), CountIF() etc., is that they can be used to perform calculations based on complex conditions
- Array functions when used over a range (and in multiple cells) would prevent any changes which happen by mistake, as a set of functions if input as an array, cannot be deleted/edited unless all cells within the array range are deleted
- These functions also ensure consistency. As array function requires the ranges in the function to be of same length, it ensures that the arguments provided with the function are correct and are not of unequal lengths
- Array functions are processed with each cell (or cell combination) processed individually. This requires system to perform same calculation over again for the all the cells mentioned in the range. This leads the system to take that extra time to calculate all array ranges again.
In case there are many array functions used in a worksheet, it can lead to re-calculations taking lot of time. - Array functions cannot be worked on whole columns or whole rows. I.e., you cannot use range names such as - A:A or B:B or C:C, etc.
- These functions are a bit difficult to understand and implement. If they are not properly worked with, they can result in results which are not accurate, and it would be difficult for one to understand what is leading to inaccurate results
A minor mistake in my previous post
=Sum(A1:A10,B1:B10)
=Sum(A1:A10*B1:B10)
Sunday, June 21, 2009
What are Array Functions or Array Formulas
- In the cells A1 to A10 write the numbers from 1 to 10
- Similarly in cells B1 to B10, write the same numbers
Now suppose, you want to multiply each cell in column A with the corresponding cell in column B and then sum it. One of the ways is to use the Sumproduct() function (I will discuss this function in later posts). And the other way is to first use column C to calculate the products of the cells and then sum them in column C.
- In cell A11 type this: =Sum(A1:A10*B1:B10)
- Now hit enter/return key
This will give you an error as though we have used the range in this function, but it has not been used as an array function.
- In cell A11 type this, but do not hit enter): =Sum(A1:A10*B1:B10)
- Now hold Ctrl+Shift keys and while holding them, hit enter/return key
A function is used as an array function by inputting the function using Ctrl+Shift keys. These two keys will display curly brackets '{}' around the function, but these actually are not there in the cell. They just show up in the cell.
Function SumSQ()
SumSQ()
This function calculates the sum of squares of the numbers provided as arguments to the function. The arguments provided to this function can be numbers, range of numbers, arrays, etc.
Syntax:
= SumSQ (Number1, Number2, Number…)
Number1, Number2, Number: These are numbers for which sum of squares is to be calculated
Example:
- = SumSQ(1, 2, 3) - result will be - 14
This function does calculation as – ((1*1) + (2*2) + (3*3)) Read more...
Function RandBetween()
RandBetween()
This function returns a random number between a given range of integer numbers
Syntax:
= Randbetween (Bottom_number, Top_number)
Bottom_number: The smallest number that the function will return
Top_number: The largest number that the function will return
Example:
= Randbetween (3,100)
Note: This function is a volatile function, i.e. this function is re-calculated whenever the worksheet gets updated. A heavy use of this function in a workbook can make your workbook calculations slow
Function Rand()
This function returns an evenly distributed random number between 0 and 1
Syntax:
=
Note: This function is a volatile function, i.e. this function is re-calculated whenever the worksheet gets updated. A heavy use of this function in a workbook can make your workbook calculations slow.
In Excel 2007, there is also an advanced version of this function: Randbetween()
Function Odd()
- = Odd (2) - result will be: 3
- = Odd (3) - result will be: 3
- = Odd (5) - result will be: 5
- = Odd (8) - result will be: 9
- = Odd (-2) - result will be: -3
- = Odd (-3) - result will be: -3
- = Odd (-5) - result will be: -5
- = Odd (-8) - result will be: -9
Function Sign()
Sign()
This function is used determine the sign (negative or positive) of a given number. It returns -1 for negative number, 1 for a positive number and, 0 if the number provided is 0
Syntax:
= Sign (Number)
Number: Number for which sign is to be determined
Example:
- = Sign (-21) – result will be: -1
- = Sign (-1) – result will be: -1
- = Sign (21) – result will be: 1
- = Sign (0) – result will be: 0
Function SQRT()
SQRT()
This is a simple function which is used to convert find a square root of a number
Syntax:
= SQRT (Number)
Number_text: Number for which the square root is to be returned
Example:
- = SQRT (4) - result willl be - 2
- = SQRT (49) - result willl be - 7
- = SQRT (11) - result willl be - 121
Function Value()
This function is used to convert a number, stored as a text, into value
Syntax:
= Value (Number _text)
Number_text: Number stored as a string/text
Example:
In the above example, I have used two functions deliberately to show the actual application of this function. In the above example, the Mid() function extracts the numbers as text, from the string – ‘B99’.
And the function Value() converts the number, extracted as text back into a proper number. The difference between the two is that a number stored as text cannot be used for any calculations, whereas a proper number can be used for calculations
Note: I have used two functions in two different cells in the above example. This, instead can be written as:
= Value( Mid( B3,2,2) ) Read more...
Function Trim()
This function removes extra blank spaces from the given text. It removes text from text from – the start of the text string, at the end of the text string, and any extra spaces between the words within a text string
Syntax:
= Trim (String)
String: a text string that may contain any extra spaces which needs to cleaned from the string
Example:
Note: In the above example, the extra spaces (represented by ‘|’ symbol) were removed using the Trim() function.
Function Substitute()
For the below examples, let us assume that cell A1 contains text - My name is Excel Matic
- = Substitute (A1, "Excel Matic", "Mohit Khurana") - result will be - My name is Mohit Khurana
- = Substitute (A1, "e", "u") - result will be - My namu is Excul Matic
- = Substitute (A1, "e", "u", 2) - result will be - My name is Excul Matic
Function Search()
- = Search ("E", "Excel Matic", 1) - result will be - 1
- = Search ("m", "Excel Matic", 1) - result will be - 7
- = Search ("E", "Excel Matic", 2) - result will be - 4 (though we started finding 'e' from second position, but the functions returns the position relative to original string, without ignoring the initials characters)
- = Search (" ", "Excel Matic", 1) - result will be - 6 (Spaces, special characters can also be found using this function)
- = Search ("E", "Excel Matic", 20) - result will be - #VALUE! (This will return an error as it is not able to find 'E' beyond the original length of the text)
- = Search ("G", "Excel Matic", 1) - result will be - #VALUE! (This will return an error as it is not able to find 'G' which is not present in the Base String)
Function Mid()
- = Mid ("Excel Matic",1 , 1) - result will be - E
- = Mid ("Excel Matic",1 , 2) - result will be - Ex
- = Mid ("Excel Matic",1 ,31) - result will be - Exc
- = Mid ("Excel Matic",1 , 4) - result will be - Exce
- = Mid ("Excel Matic",1 , 5) - result will be - Excel
- = Mid ("Excel Matic",7 , 1) - result will be - M
- = Mid ("Excel Matic",7 , 2) - result will be - Ma
- = Mid ("Excel Matic",7 , 3) - result will be - Mat
- = Mid ("Excel Matic",7 , 4) - result will be - Mati
- = Mid ("Excel Matic",7 , 5) - result will be - Matic
Function Len()
- = Len ("Excel") - result will be - 5
- = Len ("Matic") - result will be - 5
- = Len ("ExcelMatic") - result will be - 10
- = Len ("Excel Matic") - result will be - 11
- = Len ("## @@ $$") - result will be - 8 (The string here contains 6 special characters and 2 spaces)
Saturday, June 13, 2009
Function Find()
- = Find ("e", "Excel Matic") - result will be - 4
- = Find ("E", "Excel Matic") - result will be - 1
- = Find ("c", "Excel Matic") - result will be - 3
- = Find ("c", "Excel Matic",5) - result will be - 11
- = Find ("S", "Excel Matic") - result will be - #Value!
Function Exact()
- = Exact ("Excel, "Matic") - result will be - FALSE
- = Exact ("Excel, "excel") - result will be - FALSE
- = Exact ("matic, "Matic") - result will be - FALSE
- = Exact ("Excel, "Excel") - result will be - TRUE
- = Exact ("Matic, "Matic") - result will be - TRUE
Function Concatenate()
- = Concatenate ("Excel", "Matic") - result will be -ExcelMatic
- = Concatenate ("Excel", " ", "Matic") - result will be -Excel Matic (note the space between words)
- = Concatenate ("Excel", " ", "Matic", " 5.2") - result will be -Excel Matic 5.2
- = "Excel" & "Matic" - result will be -ExcelMatic
- = "Excel" & " " & "Matic" - result will be -Excel Matic (note the space between words)
- = "Excel" & " " & "Matic" & " 5.2" - result will be -Excel Matic 5.2