Friday, July 29, 2016

Alternative for SUMIF and SUMIFS

Ever wondered while using "SUMIF" function, the sum range cannot be more than one column!! This indeed is a big drawback while using a large data set where you need to sum matching certain conditions.

I often end up using multiple sumif with "+" which makes the formula very long. So was thinking of some alternative that can make life easier.

Thanks to the search engines these days, I did come across a workaround.



Refer to the above image:

In the above example, I have a table with 4 columns where H1 and H2 are identifiers. H3 and H4 is the data which needs to be summed up.

Condition 1 (alternative for SUMIF):
I need to sum values of H3 and H4 where the identifier H2 is "Y".
The formula will be =SUM(IF(B2:B5=B9,C2:D5)) followed by Ctrl + Shift + Enter which will make it a array formula. The final formula will look like this: 
{=SUM(IF(B2:B5=B9,C2:D5))}

Condition 2 (alternative for SUMIFS):
I need to sum values of H3 and H4 where the identifier H1 is "N" and H2 is "Z".
The formula will be =SUM(IF(A2:A5&B2:B5=B10,C2:D5)) followed by Ctrl + Shift + Enter which will make it a array formula. The final formula will look like this: 
{=SUM(IF(A2:A5&B2:B5=B10,C2:D5))}

Try this out in a larger data set and check your results.


Disclaimer: This will work only in a array i.e. without "Ctrl + Shift + Enter" , the result may be "#N/A"




Thursday, December 24, 2015

Solving issues with "VLOOKUP"


VLOOKUP syntax


We often encounter "#N/A" while using VLOOKUP function to compare two lists. One of the most common problems that give rise to this error is extra spaces either to the end or to the beginning of the string.

What's the way out?

The simplest way out is to use "TRIM" function as a sub function.

Example

While trying to use VLOOKUP in the normal course, the result will be "#N/A", whereas with TRIM nested in the VLOOKUP function will give the positive result.

(TRIM function removes the unwanted spaces in the beginning and end of a string.)

Saturday, February 8, 2014

Identify duplicate values in a list using "Countif"

Though MS Excel today allows to easily eliminate duplicate values in a list, have you ever tried to identify the number of entries that gets repeated in an excel list?


In the above example, we can identify the repeat entries using "COUNTIF" function.

Option 1

formula: =COUNTIF($D$1:D1,D1)
Explanation: This formula counts the occurrence of the value in the list i.e. on the first occurrence, the result will be one and on the second it will be 2 and like wise. (see the figure below)



Option 2

formula: =COUNTIF($D$1:$D$8,D1)
Explanation: This formula counts the total number of repetitions. If an entry appears thrice in a list, then the result will be 3 in all the occurrences of that entry. (see the figure below)


So start using whichever is convenient to you... :)

Thursday, January 3, 2013

Power of Data Validation - 2

Have you ever wondered if we can have a dynamic drop down list i.e. a drop down using data validation that gets updated automatically with any change in the source of the drop down...

I often faced problems having a dynamic drop down list but ultimately I was able to find a solution to my problem.

Step 1:

Format the source list as a table and name the table (here I've named the table as "Fruits")


List




Step 2:

Go to Formulas -> Name Manager and click on New



Define any name in the dialog box

In the example, I've named it as "Names". Then click on Refers to field and select the table in the excel sheet. The refer to will appear as =TableName[ColumnName]

Step 3:

Now create the drop down list using data validation and mention the source as the name you defined. In this case "Names"


Here you go. The drop down list hence created is dynamic. Any addition or deletion in the source table of the drop down options, the validated cell gets updated automatically...!!

Excel is great!

Related posts:

Tuesday, October 2, 2012

Power of Data Validation - 1

In a series where I would like to present on the power of "Data Validation" option in MS Excel, the first and commonly used function is creation of a drop down list in a cell.

We often come across situation where we feel the necessity of having a drop down list in a worksheet where the inputs are predefined and the user gets ready option to populate the cell. The easiest way to create such a dropdown is typing out the list values in the data validation -> list option.

Step 1: Go to Data -> Data Validation -> Data Validation...



 Step 2: Select "List" option in the "Allow" drop down box


 Step 3: Write down the desired list values seperating them with comma in "Source" box


Result: You get the drop down with the desired options in the intended cell
What if you intend to create a long list where the entries are too much? Don't worry, excel offers you solution for this as well. Instead of the "Step 3" listed above, follow the step as below:

Step 3 (Alternate): Create a list in any given column in the same worksheet. Then select the listed range in the "Source" box


Limitation: This option is only possible when the source list and the cell where drop down is intended are on the same worksheet.

Don't worry, Excel offers a solution even to this limitation - "Named Range"!!

Step A: Go to a new work sheet and list the contents you want to feature in the dropdown
Step B: Type any name for the list in the "Name" box as displayed in the figure below



You can review such named lists in a worksheet by going to Formulas -> Name Manager. The "Name Manager" dialogue box displays the all named ranges in a given workbook. This can be used in case you wish to modify any list in the workbook.

Step 3 (Alternate): Now go to you original worksheet where you wish to create a drop down list. In the source option write the name of the intended list (in the example: "Greek")

So here you go... now you are ready to create drop down lists in excel!

For any queries/clarifications do write in to email@arvindkumar.com

Watch out for more on the "Power of Data Validation" series!!

Related posts: