Exact match lookup with SUMPRODUCT
=SUMPRODUCT(--(EXACT(val,lookup_col)),result_col)
Case sensitive lookups in Excel
By default, standard lookups in Excel are not case-sensitive. Both VLOOKUP and INDEX/MATCH will simply return the first match, ignoring case.
A direct way to workaround this limitation, is to an array formula based on INDEX/MATCH with EXACT. However, if you're looking up numeric values only, SUMPRODUCT + EXACT also gives an interesting and flexible way to do a case-sensitive lookup.
In the example, we are using the following formula
=SUMPRODUCT(--(EXACT(E3,B3:B8)),C3:C8)
Although this formula is an array formula, it does not need to be entered with Control + Shift + Enter, since SUMPRODUCT handles arrays natively.
How the formula works
SUMPRODUCT is designed to work with arrays, which it multiplies, then sums.
In this case, we are two arrays with SUMPRODUCT: B3:B8 and C3:C8. The trick is to run a test on the values in ciolumn B, then convert the resulting TRUE/FALSE values to 1's and 0's. We run the test with EXACT like so:
EXACT(E3,B3:B8)
Which produces this array:
{FALSE;FALSE;TRUE;FALSE;FALSE;FALSE}
Note that the true value in position 3 is our match. Then we use the double negative (i.e. --, which is technically a "double unary") to coerce these TRUE / FALSE values into 1 and 0. The result is this array:
{0;0;1;0;0;0}
At this point in the calculation, the SUMPRODUCT formula looks like this:
=SUMPRODUCT({0;0;1;0;0;0},{875;750;775;675;800;825})
SUMPRODUCT then simply multiples the items in each array together to produce a final array:
{0;0;775;0;0;0}
Which SUMPRODUCT then sums, and returns 775.
So, the gist of this formula is that the FALSE values are used to cancel out all other values. The only values that survive are those that were TRUE.
Note that because we are using SUMPRODUCT, this formula comes with a unique twist: if there are multiple matches, SUMPRODUCT will return the sum of those matches. This may or may not be what you want, so take care if you do expect multiple matches!
Remember, this formula only works for numeric values, because SUMPRODUCT does't handle text. If you want to retrieve text, use INDEX/MATCH + EXACT.
Find missing values
=IF(COUNTIF(list,value),"OK","Missing")
If you want to find out what values in one list are missing from another list, you can use a simple formula based on the COUNTIF function.
The COUNTIF function counts cells that meet supplied criteria, returning the number of occurrences found. If no cells that meet criteria are found, COUNTIF returns zero. You can use behavior directly inside an IF statement to identify values that have a zero count (i.e. values that are missing).
In the example shown, the formula in G6 is:
=IF(COUNTIF(list,F6),"OK","Missing")
where "list" is a named range that corresponds to the range B6:B11.
The IF function requires a logical test to return TRUE or FALSE. In this case, if a value is found, a positive number is returned by COUNTIF, which evaluates to TRUE, causing IF to return "OK". If no value is found, zero is returned, which evaluates to FALSE, and IF returns "Missing".
Alternative with MATCH
You can also test for missing values using the MATCH function. MATCH finds the position of an item in a list and will return the #N/A error when a value is not found. You can use this behavior to build a formula that returns "Missing" or "OK" by testting the result of MATCH using another function called ISNA. ISNA returns true only when it receives the #N/A error.
To use MATCH as shown in the example above, the formula is:
=IF(ISNA(MATCH(F6,list,0)),"Missing","OK")
Note that MATCH must be configured for exact match. To do this, make sure the third argument is zero or FALSE.
Alternative with VLOOKUP
Since VLOOKUP also returns an #N/A error when a value isn't round, you can build a formula with VLOOKUP that works the same as the MATCH option. As with MATCH, you must configure VLOOKUP to use exact match, then test the result with ISNA. Also note that we only give VLOOKUP a single column (column B) for the table array.
Financial Functions
Pmt | Rate | Nper | Pv | Fv
To illustrate Excel's most popular financial functions, we consider a loan with monthly payments, an annual interest rate of 6%, a 20-year duration, a present value of $150,000 (amount borrowed) and a future value of 0 (that's what you hope to achieve when you pay off a loan).
We make monthly payments, so we use 6%/12 = 0.5% for Rate and 20*12 = 240 for Nper (total number of periods). If we make annual payments on the same loan, we use 6% for Rate and 20 for Nper.
Pmt
Select cell A2 and insert the PMT function.
Note: The last two arguments are optional. For loans the Fv can be omitted (the future value of a loan equals 0, however, it's included here for clarification). If Type is omitted, it is assumed that payments are due at the end of the period.
Result. The monthly payment equals $1,074.65.
Tip: when working with financial functions in Excel, always ask yourself the question, am I making a payment (negative) or am I receiving money (positive)? We pay off a loan of $150,000 (positive, we received that amount) and we make monthly payments of $1,074.65 (negative, we pay).
Rate
If Rate is the only unknown variable, we can use the RATE function to calculate the interest rate.
Nper
Or the NPER function. If we make monthly payments of $1,074.65 on a 20-year loan, with an annual interest rate of 6%, it takes 240 months to pay off this loan.
We already knew this, but we can change the monthly payment now to see how this affects the total number of periods.
Conclusion: if we make monthly payments of $2,074.65, it takes less than 90 months to pay off this loan.
Pv
Or the PV (Present Value) function. If we make monthly payments of $1,074.65 on a 20-year loan, with an annual interest rate of 6%, how much can we borrow? You already know the answer.
Fv
And we finish this chapter with the FV (Future Value) function. If we make monthly payments of $1,074.65 on a 20-year loan, with an annual interest rate of 6%, do we pay off this loan? Yes.
But, if we make monthly payments of only $1,000.00, we still have debt after 20 years.
Where the arguments are as follows:
rate
|
-
|
The interest rate, per period.
|
nper
|
-
|
The number of periods for the lifetime of the annuity.
|
[pmt]
|
-
|
An optional argument that specifies the payment per period.
(Note that if the [pmt] argument is omitted, the [pv] argument must be supplied).
|
[pv]
|
-
|
An optional argument that specifies the present value of the annuity - i.e. the amount that a series of future payments is worth now.
(If the [pv] argument is omitted, it takes on the default value 0. Also, if [pv] is omitted, the [pmt] argument must be supplied).
|
[type]
|
-
|
An optional argument that defines whether the payment is made at the start or the end of the period.
The [type] argument can have the value 0 or 1, meaning:
0 - the payment is made at the end of the period;
1 - the payment is made at the beginning of the period.
If the [type] argument is omitted, it takes on the default value of 0 (denoting payments made at the end of the period).
|
Dostları ilə paylaş: |