The post XLOOKUP Two-way approximate match multiple criteria appeared first on CrispExcel.com.
]]>Having read Dave’s article I thought… “Is there an easy way of doing this using XLOOKUP instead of INDEX/MATCH?”
The aim was to return the feed rate (D6:H16) given the material, hardness and diameter.
There are 2 tricks to getting the function working correctly.
=XLOOKUP(K5&K6,
//Return Combo multiple criteriamaterial&hardness,
//Return Combo lookup arrayXLOOKUP(K7,diameter,data,,-1),,-1)
The outer XLOOKUP Combines the material and hardness criteria and creates a combo lookup array of Materials & Hardness.
NB: This ability of XLOOKUP to instantly create and search a combo array makes it suitable for multiple criteria search. It is extremely hard to do this with any other lookup function
Also, unlike the INDEX/MATCH function, you do not need to sort the diameter and hardness data in ascending order.
RELATED ARTICLES
The post XLOOKUP Two-way approximate match multiple criteria appeared first on CrispExcel.com.
]]>The post WTF with XLOOKUP Function appeared first on CrispExcel.com.
]]>Excel experts called it “Functions Killer“, “Ultimate Lookup Function“, “Single Most Important function“, “Excel Chicken Soup of the Soul” e.t.c
Some experts actually shared a video terming anyone who continues to use the old methods a “Pariah” with a signed declaration and peace summit in honor of XLOOKUP.
So, What’s The Fuss (WTF) With XLOOKUP?
=XLOOKUP(Look-up value, Look-array, Return-value)
In layman’s language
=XLOOKUP(what value are you looking for, which column/row has these values, what do you want to retrieve/return)
Compare this with excel most famous Look up function VLOOKUP
=VLOOKUP(Lookup_Value, Table_Array, Col_index_Num, [range_lookup])
By the time you understand what is a Table array, count which column number the return value(s) is and remember the default is approximate match, you are already lost
Here are the 11 things that could be generating all this Fuss;
The most common mistake for novice excel users is forgetting VLOOKUP & MATCH (mostly used as INDEX/MATCH) default into Approximate Match.
This is no longer the case with XLOOKUP–It defaults to Exact match which is what most users are looking for when doing a search.
For example, using below data, look up delivery date for Supplier Id “Ja44”?
VLOOKUP returns a wrong date if you forget to specify the Match mode (range_lookup) but XLOOKUP returns the correct date. See image below
XLOOKUP belongs to the new Dynamic array formulas in excel that allows one to return multiple results to a range of cells.
This range is commonly known as Spill Range which can either be multiple rows/columns or as a table.
Using the previous data, let us look up the delivery date, Office supplies, Furniture, and Computers for Supplier Id “Ja44”?
Another beauty of XLOOKUP is its ability to do a left lookup without the help of another function. (Neither INDEX nor VLOOKUP can do this dynamically without the help of MATCH Function)
For VLOOKUP to look up to the left you have to modify it as shown below
=VLOOKUP(H2,IF({1,0},Table1[Order ID],Table1[Product ID]),2,FALSE)
Unlike VLOOKUP, XLOOKUP handle Insertions and Deletion of rows/colums smoothly just like INDEX & MATCH
But unlike INDEX & MATCH, this is not a combo formula but a simple and easy to understand single function
VLOOKUP can handle the insertion & deletion of columns with the help of MATCH function
No more need for HLOOKUP or the Combo formula INDEX & MATCH, XLOOKUP takes the day.
XLOOKUP has the ability to do a search using a fuzzy or approximate Match. This is where the text values are not an exact match.
No need to install Fuzzy Lookup Add-In for Excel!
Excel MVP Wyn Hopkins has done a good speed test . See for yourself
Just like INDIRECT, INDEX or OFFSET, XLOOKUP returns a reference to a cell and thus can be used to create dynamic ranges.
You can easily search for the last or first entry in a list using XLOOKUP.
Prior to XLOOKUP, one has to nest a look up function inside IFERROR.
This is no longer the case!
XLOOKUP has inbuilt “if no match” found which can return a value or nest another function.
INDEX and MATCH has been a favourite of many while doing a 2-way lookup but XLOOKUP may change the hearts of many.
This requires a nested XLOOKUP. The trick is to spill the return array first and then use another XLOOKUP to search it
It is easy for XLOOKUP to return data from multiple continuous columns. You just select them in the return arrays and the values will be spilled.
For discontinous columns, you need to nest IF function to select the columns.
=XLOOKUP( H2, Sales[Supp ID], IF({1,0},Sales[Delivery Date],Sales[Computers]) )
NB: IF function can only help you return 2 discontinuous columns. When you want more than 2 columns then use SWITCH or CHOOSE functions
=XLOOKUP(H2,Sales[Supp ID], SWITCH({1,2,3},1,Sales[Delivery Date],2,Sales[Computers],Sales[Supplier Name])) or CHOOSE Function =XLOOKUP(H2,Sales[Supp ID], CHOOSE({1,2,3},Sales[Delivery Date],Sales[Computers],Sales[Supplier Name]))
Bonus: If you wish to return All returned values in one cell, wrap the XLOOKUP with TEXTJOIN
=TEXTJOIN(",",TRUE, XLOOKUP(H2,Sales[Supp ID],CHOOSE({1,2,3},Sales[Delivery Date],Sales[Computers],Sales[Supplier Name])) )
Conclusion:
XLOOKUP may not be the panacea for all excel lookup problems, neither may it be the “Excel Chicken Soup of the Soul” but if you are looking for an all-in-one lookup function…then this is it.
Sadly this function is only available in Office365. If you don’t have Office365, then learn, VLOOKUP, HLOOKUP, INDEX & MATCH, & LOOKUP.
Now you know WTF…What’s The Fuss is all about!
The post WTF with XLOOKUP Function appeared first on CrispExcel.com.
]]>“Excel Flash Fill Is A Brilliant Time Saver,” writes Life hacker Australia. “In fact, it’s so good it feels like magic,” says Tech Radar
“Flash Fill brings the power of text manipulation to the hands of common, non-technical, everyday users. Even people who aren’t familiar with Excel can use the feature,” says Chad Rothschiller, a program manager with the Excel 2013.
CNN Money calls Excel Flash Fill as “Excel 2013’s coolest new feature that should have been available years ago”
So, What is this Flash fill? Where did it come from? How can it make excel-dummies work like Pros? Is it going to eliminate formulas & Macros?
Excel Flash Fill is a Programming by Example (PBE) data manipulation tool that is applying machine learning to binary decision diagrams. Flash fill automates repetitive string transformations using examples. Once the user performs one/two instances of the desired transformation, flash fill learns from these and replicates the transformation in all other rows.
Its origin was a simple act of kindness when Sumit Gulwani, a senior researcher at Microsoft attempted to help a business lady to merge cells but he couldn’t due to his lack of excel skills. For 4 years he embarked on collaborative research in an attempt to bring machine learning and programming to the masses of non-tech users–Excel Flash fill was born.
How do you access Flash fill?
Please note Flash fill is ONLY available in Excel 2013 and later.
Ctrl + E is the keyboard shortcut or Go to Data Under Data Tools
This article shows you the diverse ways that Flash fill can save you time and make you look like a Pro.
This is a 3 Simple Step process. No more writing concatenation formulas or Macros
Sometimes Flash Fill requires more than 1 example to “read your Mind”.
This requires a 2nd or a 3rd example as shown below.
Assume you have a combined description and you desire to split it into respective columns.
With Excel flash fill, you no longer need to know complex string manipulation formula like below
=MID(A2, SEARCH(" ",A2) + 1, SEARCH(" ", A2, SEARCH(" ", A2) + 1) - SEARCH(" ", A2) -1)
NB: For Flash Fill to work with dates, Ensure you format cells in the date column to “dd/mm/yyyy”
3.Complex Extraction of Text String
The more complex the string manipulation the more examples that excel flash fill requires.
Previously, to extract the substring between 1st and 2nd hyphens shown above, you will be required to write below formula
=MID(A2,
FIND(CHAR(1),SUBSTITUTE(A2,"-",CHAR(1),1))+1,
FIND(CHAR(1),SUBSTITUTE(A2,"-",CHAR(1),2)) - FIND(CHAR(1),SUBSTITUTE(A2,"-",CHAR(1),1))-1
)
Excel Flash Fill saves time and headache but you will need a few examples to teach it your required outcome.
Excel Flash fill can also be used to custom format numbers from simple to complex.
For example, if you want to store below telephone numbers by adding a preceding zero, grouping 1st 3 numbers using a bracket and separating the other two groups using a hyphen.
Either Use below formula
="(0"&RIGHT(A3,3)&")"&"-"&(MID(A3,4,3))&"-"&LEFT(A3,3)
Or Just show Excel Flash fill one desired example
Extracting numbers in a string can be very sophisticated and require advanced excel programming skills.
Excel flash fill makes extracting numbers look like child play.
For example, to extract numbers in the below example, you need this formula;
=IF(
SUM(LEN(A2)-LEN(SUBSTITUTE(A2, {"0","1","2","3","4","5","6","7","8","9"}, "")))>0,
SUMPRODUCT(
MID(0&A2,
LARGE(INDEX(ISNUMBER(--MID(A2,ROW(INDIRECT("$1:$"&LEN(A2))),1))*ROW(INDIRECT("$1:$"&LEN(A2))),0),
ROW(INDIRECT("$1:$"&LEN(A2))))+1,1)*
10^ROW(INDIRECT("$1:$"&LEN(A2)))/10),
""
)
NB: If you have Leading Zeros, ensure you format the extracting column as text.
Generating a list that has carriage return like postal addresses requires a very complex formula or a Macro.
If you go the formula way, there is a likelihood you may slow down your spreadsheet.
See below the Flash Fill Magic that any Excel dummy can execute.
NB: To avoid the article over-flowing, other 7 uses will be addressed in Part 2
It is not all rosy with Flash Fills as it has a number of weaknesses;
99% of computer users do not know programming and struggle with repetitive tasks.
This should no longer be the case! Let Excel flash fill do the heavy lifting
Excel Flash fill brings to every excel user ability to use machine learning and programming.
More resources
Excel 2013 Flash Fill: 23 Amazing Examples
More info on Programming By Example
Using Flash Fill to Clean Data
Flash Fill: Text wrangling for non-programmers
MORE ARTICLES
FIND THE LAST OR NTH OCCURRENCE IN EXCEL USING MULTIPLE CRITERIA
The post Excel Flash Fill: 15 Things You Can Do In a Flash. Part 1 appeared first on CrispExcel.com.
]]>The post 4 ways to lookup items not matching a list appeared first on CrispExcel.com.
]]>For example, below we have a list of mechanics and assigned car to service. If only 3 cars were serviced, how do you retrieve the lazy mechanics?
Here is the formula;
{=INDEX( Table13[Mechanics], SMALL( IF( COUNTIF(Car_Serviced,Table13[Car to Service])=0, ROW(Table13[Mechanics])-1 ) ,ROW(C1)))}
How it Works:
►COUNTIF(Car_Serviced, Table13[Car to Service]) returns a count of 1 for the serviced car and 0 for unserviced cars
{0;0;1;0;1;1;0;0;1;0;1;1;1;0;0;1;0;1;1;0;1;0}
►Since we are interested with the unserviced car, Car_Serviced, Table13[Car to Service])=0, returns an array of TRUE & FALSE
{TRUE;TRUE;FALSE;TRUE;FALSE;FALSE;TRUE;TRUE; FALSE;TRUE;FALSE;FALSE;FALSE;TRUE;TRUE;FALSE; TRUE;FALSE;FALSE;TRUE;FALSE;TRUE}
►IF function returns the Rows (ROW(Table13[Mechanics])-1) for the mechanics where the condition is TRUE. NB: We deduct 1 to cater for the heading row
SMALL( {1;2;FALSE;4;FALSE;FALSE;7;8;FALSE;10;FALSE;FALSE;FALSE;14;15;FALSE;17;FALSE;FALSE;20;FALSE;22} ,ROW(C1))
►SMALL function, using the k Value supplied by (ROW(C1)) returns the row numbers from smallest to largest which INDEX function uses to look up the mechanic’s name
PS:
{=IFERROR( INDEX(Table13[Mechanics], SMALL( IF(COUNTIF(Car_Serviced,Table13[Car to Service])=0,ROW(Table13[Mechanics])-1) ,ROW(C1) )),"")}
Power Query is here to make the life of a Data Analyst easy. This method assumes you have the basics of power query skills, if not, Check this course on Power Query Fundamentals to Expert
Steps:
►Load the tables to power query; Click on a table→Go to Power query→Click “From Table/Range”. Repeat process for car serviced table
►From Power Query, close & load the table as a connection. Repeat process for car serviced table
►Now that you have 2 Workbook queries, Click on Merge.
►Select the two tables→Click on the two matching columns→Select the Left Anti-Join kind
►On the Query editor, delete the unnecessary columns then Close & load to
►Load the query as a table→to existing worksheet→select a cell to load the table
That’s all you need!
If this looks complicated for you, Check this course on Power Query Fundamentals to Expert
What if you need to look up for the Mechanics who serviced their cars i.e. Whose cars were on the list?
Easy!!
Just Change the Join type to ” Inner Join” as shown below.
Query Storm is a powerful Excel add-in for anyone who wants to utilize their T-SQL skills in excel.
It makes it easy to query and modify data in Excel as if the data was in a SQL database.
Follow below steps after installing & taking a simple introduction of the Query Storm add-in
► Go to Query Storm→Connect (SQLite)
► On the new query window, write below the anti-join query→Run query. NB: Ensure your tables are well labeled.
SELECT Mechanics FROM Mechanic_Cars mc WHERE NOT EXISTS (SELECT * FROM Serviced s WHERE mc.[Car Serviced]=s.[Car Serviced])
► Write back the results in Excel. Ensure you give the table a name. That’s All.
Excel advanced filter is one helpful tool if you know how to use it. The below method assumes you are conversant with Using formulas within the advanced filter criteria range.
Here are the steps:
►Set up a criteria area and type this formula, =COUNTIF($D$2:$D$4,B2)=0. The formula finds all the cars to be serviced that was actually serviced and returns 1. Since we are interested in unserviced cars we make it equal 0
►Go to DATA, Advance Filter, select the list of mechanics & cars, select criteria, and finally area to copy.
NB: Select the only column to copy, type the column header on the section as shown above.
There is no one way of doing anything!
Always strive to look for and learn alternatives, you never know when they may come in handy.
If I have missed any method, let me know in the comments.
The post 4 ways to lookup items not matching a list appeared first on CrispExcel.com.
]]>The post 5 Ways to Lookup Unique Values in Excel appeared first on CrispExcel.com.
]]>This article shows 5 ways to tackle duplicate data menace and create a dynamic lookup table with unique values.
The task is to create a dynamic lookup list of unique customers in the table below.
Follow the below steps:
What if you do not have Power Query installed?
No worries, write below formula and drag it down.
{=INDEX(Customer_Name,MATCH(0,COUNTIF($F$1:F1,Customer_Name),0))}
How the formula works:
COUNTIF($F$1:F2, Customer_Name)► counts the number of times a customer is occurring in Unique column (column F)
{1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0}
MATCH(0,COUNTIF($F$1:F2,Customer_Name),0)► Returns the relative position of the first zero (0) in the values generated by COUNTIF function
Then INDEX function using the position returned by MATCH function to look up the customer in that row.
NB:
{=IFERROR(INDEX(Customer_Name,MATCH(0,COUNTIF($F$1:F1,Customer_Name),0)),””)}
After posting the article on Linkedin, Lukasz Komarewicz’s comment on the use of pivot table gave rise to this 3rd method.
Here are the steps;
►Insert Pivot table, Select a location in the Existing worksheet. Click Ok.
► Select the customer name only and close the pop-up
►Rename the field, Go to the pivot table design, Grand Totals and turn off grand totals
That’s all, you will have a dynamic list of unique values. All you need is to right-click it and refresh to update
This last method is the easiest in looking up unique values. However, it does not create a dynamic list.
Here are the steps:
►Copy and past the customer’s list on a new column.
►Go to DATA, Remove Duplicates and on the pop-up window click OK. Rename the list
Edit 2:
The second comment on my Linkedin article by William J Crabtree gave birth to this fifth method.
However, like the remove duplicate method, this method also does not create a dynamic list–just a static list of unique values.
Here are the steps:
►Copy customers list, then go to the DATA tab and click Advanced.
►On the advanced filter tab, Select “copy to another location”, then select a location to “copy to”.
►Finally, select Unique records and click OK…That’s All!!!
Download the Worksheet and try it yourself
If I have missed any other method, leave a comment and let me know.
The post 5 Ways to Lookup Unique Values in Excel appeared first on CrispExcel.com.
]]>The post 4 WAYS TO SUM DATA BY WEEK NUMBER appeared first on CrispExcel.com.
]]>Excel has a beautiful but overlooked function (WEEKNUM) that returns an integer representing the week in the year (1 to 53).
For anyone not familiar with WEEKNUM function, it contains 2 arguments; Serial_number ( the date to return the week number for) and an optional Return_type (an integer that defines when the week starts).
NB: If the return type is omitted, function defaults to week start on Sunday all the way to Saturday
=WEEKNUM( serial_number, [return_type] )
[return_type] | Meaning |
---|---|
1 | Week from Sunday to Saturday |
2 | Week from Monday to Sunday |
11 | Week from Monday to Sunday |
12 | Week from Tuesday to Monday |
13 | Week from Wednesday to Tuesday |
14 | Week from Thursday to Wednesday |
15 | Week from Friday to Thursday |
16 | Week from Saturday to Friday |
17 | Week from Sunday to Monday |
21 | Week from Monday to Sunday |
Beautiful as the function is, it has one major weakness, WEEKNUM doesn’t accept a range argument e.g. =WEEKNUM(K11:K110)
just returns #VALUE! error.
So, How do you get week numbers in an array given a range of dates?
Do you need to always use a helper column to convert dates to week numbers before any analysis is done?
In this article, I will show you 3 ways to simplify your weekly analysis:
Given the below data, Show totals per week.
Since WEEKNUM does not accept a range argument, then we have to create a helper column so that we can be able to use SUMIF
It is not entirely true that WEEKNUM does not accept a range argument. It can be forced to accept range by adding zero to a range i.e.
=WEEKNUM(A1:A25+0)
The above function does not return an error but an array of week numbers from the given dates range.
Since SUMPRODUCT function comfortably handles arrays, we can use this array of week numbers to create a summary as shown below.
=SUMPRODUCT( (WEEKNUM(Table13[Order Date]+0)=[@[Week No.]]) *Table13[Sales] )
How it works:
►WEEKNUM(Table13[Order Date]+0) returns an array of week numbers for the given date range
{34;23;23;45;45;24;24;35;16;16;23;35;35;45;23;45;35;34;35}
►WEEKNUM(Table13[Order Date]+0)=[@[Week No.]] returns an array of TRUE/FALSE based on the week number criteria.
{TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE; FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;TRUE;FALSE}
►(WEEKNUM(Table13[Order Date]+0)=[@[Week No.]])*Table13[Sales] During this multiplication, the above array of TRUE/FALSE is converted into its numeric equivalent of 1/0 which is multiplied with the sales figure. Below is the result;
{18.504;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;68.81;0}
--this array is fed to SUMPRODUCT for the final additions
=SUMPRODUCT({18.504;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;68.81;0})=87.314
This is an array function that uses the same principles as SUMPRODUCT
{=SUM(IF(WEEKNUM(Table135[Order Date]+0)=[@[Week No.]],Table135[Sales]))}
How it works:
►WEEKNUM(Table13[Order Date]+0)=[@[Week No.]] returns an array of TRUE/FALSE based on the week number criteria.
{TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE; FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;TRUE;FALSE}
►IF function returns only the Sales values if the test is TRUE, otherwise returns FALSE
{18.504;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE; FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE; FALSE;68.81;FALSE}
►Since SUM function ignores texts, It just sums up the numbers
=SUM({18.504;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE; FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;68.81;FALSE})=87.314
This is the simplest and easiest method.
Its only major drawback is that it will give you the week’s date range but not the week number.
NB: The trick in using the pivot table is knowing how to group the dates into weeks. Watch the video again.
There is now no need to lose your hair over worrying about how to do weekly summaries.
You can use the same techniques taught above to do Average and Count.
If I have missed something, share.
DOWNLOAD SPREADSHEET FOR PRACTICE
The post 4 WAYS TO SUM DATA BY WEEK NUMBER appeared first on CrispExcel.com.
]]>The post VLOOKUP IS DEAD–OR IS IT? appeared first on CrispExcel.com.
]]>There has been a similar discussion in the Excel world, not about God, but about VLOOKUP.
Of all the over 450 functions in Excel, VLOOKUP is one of the most popular and most controversial function.
All excel users can be divided into 2: VLOOKUP die-hards and VLOOKUP bashers. Both sides have evidence to prove their stand.
I have a confession to make, I have been a VLOOKUP basher for a long time until I started to listen to the other side. By softening my hard-stand I have learned a lot that has chattered the many myths I have held about this function.
This is an Article on demystifying the 5 great Myths about VLOOKUP.
Let’s tackle the Elephant in the Room first. This is the widest spread myth about VLOOKUP.
According to this Myth, You can only use Order ID (see image below) to get either Customer ID or Customer Name as these data are stored in the columns to the right of Order ID.
So what happens when you want to get Product ID, Order Date using the Order ID?
Is it true that VLOOKUP only looks to the right?
NO!
Not only does it look Left but there are 2 ways to make it look left;
Using VLOOKUP and IF function you can get Product ID using Order ID as shown below
=VLOOKUP(H2,IF({1,0},Table1[Order ID],Table1[Product ID]),2,FALSE)
How It Works:
The Trick is to create your own Table array using the IF function.
IF({1,0},Table1[Order ID],Table1[Product ID]) creates a range where Product ID appears to the right of OrderID. This Rearrangement makes VLOOKUP get the Product ID
{"CA-2016-152156","FUR-BO-10001798";
"CA-2016-138688","FUR-CH-10000454";
"US-2015-108966","OFF-LA-10000240";
"CA-2014-115812","FUR-TA-10000577";
"CA-2017-114412","OFF-ST-10000760";
"CA-2016-161389","FUR-FU-10001487";
"US-2015-118983","OFF-AR-10002833";
"CA-2014-105893","TEC-PH-10002275";
"CA-2014-167164","OFF-BI-10003910";
"CA-2014-143336","OFF-AP-10002892";
"CA-2016-137330","FUR-TA-10001539";
"US-2017-156909","TEC-PH-10002033";
"CA-2015-106320","OFF-PA-10002365";
"CA-2016-121755","OFF-BI-10003656";
"US-2015-150630","OFF-AP-10002311";
"CA-2017-107727","OFF-BI-10000756"}
CHOOSE Function can also be used to rearrange your Table array in such a way that Product ID appears to the RIGHT of the Order ID
=VLOOKUP(H3,CHOOSE({1,2},Table1[Order ID],Table1[Product ID]),2,FALSE)
Note: CHOOSE function creates a range where Order ID appears to the LEFT of Product ID just like IF function above.
NB: VLOOKUP can be “Tricked” to think it is looking to the RIGHT while it is actually looking to the LEFT because its Table_Array can be a Range either from a Syntax eg: A1: F18 or it can be a Named range Formula or it can be a formula that returns a Range as a solution.
It is widely taught that VLOOKUP can only get data from one Column.
Well!, This is not True.
VLOOKUP can return data from as many columns as you want.
For example, given the Product ID, how can you get the OrderDate, Customer ID & Customer Name?
Below is how to do it
{=VLOOKUP(G2,A1:E16,{2,4,5},FALSE)}
Another Widely spread myth is that VLOOKUP can only have a single ‘lookup_value
’. Therefore if your data has duplicates, it will be hard to use VLOOKUP.
Again! This is not TRUE!
VLOOKUP can do Multiple criteria Lookup.
All you need is to modify VLOOKUP with an ampersand and IF function.
For example, below we have duplicate sales for a product to different customers. Given the product and customer, ID find the Order ID
Here are the steps:
I had forgotten this known myth until Shane Devenshire reminded me of it after posting the article on Linkedin.
The myth goes like since you are hard-coding the column index number on the formula, your results will always be tampered with every time you add or delete the column.
This is not TRUE!
VLOOKUP can handle the Insertion & Deletion of columns.
You can have a workaround with the MATCH function to provide a dynamic column index number.
See the below Image.
This was another forgotten myth until Shane Devenshire reminded me of it.
There are some truths and a couple of lies in this myth too.
After testing the two functions in a worksheet containing over 8000 rows I found that VLOOKUP is marginally faster than INDEX/MATCH when doing a right Lookup but fails significantly while doing a left lookup.
This is because of the “panel beating” that VLOOKUP goes through in order to do a left lookup.
CONCLUSION:
I hope this article has made you loosen your stand if you have always condemned VLOOKUP.
All the same, like all excel function there are things that VLOOKUP cannot do (at least for now until someone finds how)
If you know how it can do above three things without a helper column, Please share the knowledge
This post was inspired by a number of articles. See a few below:
The post VLOOKUP IS DEAD–OR IS IT? appeared first on CrispExcel.com.
]]>The post 7 EXCEL TABLES BEST KEPT SECRETS appeared first on CrispExcel.com.
]]>If you have never or not recently used excel tables, it could be because you have not realized how powerful they are in data analysis.
By reading below 7 excel table’s secrets, your answer to above question will always be recent.
There are 2 ways of creating an excel table: Select any cell on your data, Go to HOME tab, under styles, click format as table and then select table format. Finally, click OK on the “FormatAsTable” Dialogue box that appears. This is the most common method used but it is too long.
The simplest way to create an excel table is by use of a shortcut “Ctrl +T”. Select anywhere in your data then Ctrl +T and then click OK on Create Table Dialogue.
One of the biggest mistakes excel users make when using pivot tables is the failure to include in the pivot table analysis extra rows or columns added to their data source. This can be easily sorted by use of Excel tables.
Excel tables automatically expand to include the new rows and columns in the table saving time to check if you have included all data. All that is required is to hit refresh in and your pivot table is fully updated.
Furthermore, you can easily convert a table to a pivot table with just one click. Under Table tools in Design tab, Click Summarize with PivotTable. That’s All!
Slicers are excellent tools for data visualization, especially creating dashboards. These work best when data is formatted as an excel table.
To easily filter table data using slicers, select the table, Under Design tab, Select insert Slicer
Select the column you want to create slicers for and then OK.
az
Excel creates a Slicer as shown in the image below which is an excellent way to filter tables:
You can easily create a one-line summary on the table without writing any formula.
To do this, Under Design Tab, tick Total Row.
Click the total figure and you will find a drop down that has more summary types you can apply by just clicking on any of them.
Manually updating chart data range is hectic and prone to errors. With Excel table, your chart data range is automatically expanded.
To do this, Select Columns in the table to create a chart, then Insert the chart. As Excel tables automatically expand to include the new rows and columns in the table, so will the chart labels and values be expanded.
This is far much easier than using the indirect and offset functions to create a dynamic chart.
Running totals are important in data analysis as they show the overall progress. Excel tables structure enables a quick insert of calculated fields which is the best fit for running totals.
For example to add a running totals column in below sales data, just type below simple sum formula on a column adjacent to the last column in the table. When you hit the enter button, excel table instantly applies the formula to all other cells in that table creating a column that contains running totals.
This is possible because of the structured reference format of the formula, a feature unique in excel tables.
With just that one formula, you get below accurate running totals
Most Excel users are used to cell referencing which is mostly hard to understand.
Excel tables introduced structured references which are easily explainable especially in a formula created outside the excel table.
Structured reference syntax = Table name [Column name]
For example, in below formula, you can tell the count range is data contained in products column which is in a table called sales.
=COUNTIF(Sales[Product],"Paper")
In case you need to drag your formula across, the easiest way to create a Column Absolute reference is to create a duplicate column name separated by a full colon.
=COUNTIF(Sales[[Product]:[Product]],G1)
As you can see from above discussion, the whole aim of excel tables is to make a data analyst life simple.
So, does your life seem complicated?
Check out if you are using Excel tables and include them in your daily excel work.
For further reading check out this article: https://support.office.com/en-us/article/Using-structured-references-with-Excel-tables-f5ed2452-2337-4f71-bed3-c8ae6d2b276e
Interesting Links
4 WAYS TO SUM DATA BY WEEK NUMBER
The post 7 EXCEL TABLES BEST KEPT SECRETS appeared first on CrispExcel.com.
]]>The post 7+ WAYS TO LOOKUP NUMBER VALUES appeared first on CrispExcel.com.
]]>The more lookup function you know the better you become in retrieving numbers like sales for a certain month, a balance for a customer, the price of a product, production for a certain day, etc.
As long as the return value is numeric any of these formulas will work.
Here are the 7+ ways to lookup numerical values:
For example, using below data lookup sales values for the month of August
How it works
=SUMPRODUCT((A2:A13=D2)*(B2:B13))
►(A2: A13=D2) Returns an array of TRUE/FALSE which SUMPRODUCT converts into 1/0
► (B2: B13) Returns an array of sales values
The sum of the product of the above two arrays equals sales for the criteria month
How It Works
=SUMIF(A2:A13,D2,B2:B10)
►A2: A13 represents our Months criteria range
►D2 represents our criterion month (August)
►B2: B10 represents our sales values to lookup
The syntax for Reference;
=AGGREGATE(function_num, options, ref1, [ref2], …)
The syntax for Array;
=AGGREGATE(function_num, options, array, [k])
Function_num a number between 1 and 19 that determines which function to use.
Function 1 to 13 use reference form
While Functions 14 to 19 use array form
Options a number between 0 and 7 that determines which values to ignore during an evaluation
NB:
How It Works
=AGGREGATE(14,7,B2:B13/(A2:A13=D2),1)
{#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0! ;113809;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!}
Value—The Search value
Lookup_range—A single row or single column where LOOKUP function searches for the value. NB: Data should be sorted in ascending order
Result_range—an Optional single row or a single column of data that contains the value to be returned. NB: Must be the same size as the Lookup_range.
How It Works
=LOOKUP(1,1/(A2:A13=D2),B2:B13)
{#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0! ;1;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!}
INDEX
Array—the range of cells or an array constant
row_num—the row number/position in the selected array from which to return a value
col_num—the optional column number/position in the selected array from which to return a value
MATCH
lookup_value—the value you want to return its position
lookup_array—the array within which to search for the value
match_type—optional numbers between -1 and 1 that specifies how excel searches for the lookup_value in the lookup_array. The default value is 1.
How It Works
=INDEX(B2:B13,MATCH(D2,A2:A13,0))
There is not much difference between MAX and MAXA. See this article for an explanation
How It Works:
{=MAX((A2:A13=D2)*B2:B13)}
or
{=MAXA((A2:A13=D2)*B2:B13)}
The method exploits the fact that Excel recognizes internally the value of TRUE as number 1 and the value of FALSE as 0.
►(A2: A13=D2) checks for the August month in the array of months and returns TRUE/FALSE which Excel recognizes as 1/0.
=MAX(
{FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;FALSE}
*B2:B13
)
►Since only 1 check will evaluate to TRUE, if you multiply them with corresponding sales values, the result will be zeros plus the correct sales value.
=MAX({0;0;0;0;0;0;0;113809;0;0;0;0})
►MAX function then returns this sales values since it is the maximum in the array.
NB:
Syntax =VLOOKUP( lookup_value, table_array, col_index_num, [range_lookup] )
How it works
=VLOOKUP(D2,A1:B13,2,FALSE)=113809
VLOOKUP uses the exact match criteria to retrieve the sales values in Column 2 of the table ($F$2:$G$8).
Thanks to Shane Devenshire in a Linkedin Group who pointed out that all database functions can do this single lookup.
If you are not familiar with database functions, you are missing a lot. Start Here EXCEL DATABASE FUNCTION
Syntax = DSUM(Database, Field, Criteria)
NB: A Criteria Area that should be structured in such a way that for every Field name there is a cell below it where you enter the criterion to be met.
How it works:
For example, DSUM
=DSUM(A1:B13,E1,D1:D2)
Above steps will also work for all below database functions
=DMIN(A1:B13,B1,D1:D2)
=DAVERAGE(A1:B13,B1,D1:D2)
=DGET(A1:B13,B1,D1:D2)
=DPRODUCT(A1:B13,B1,D1:D2)
=DMAX(A1:B13,B1,D1:D2)
Slicers are a powerful way of filtering data. For them to work, the data has to be formatted as a table.
To convert a range to a table, select the whole range and press Ctrl+T.
Under table tools, click Insert Slicer, click the criteria field and press OK.
Select the Month required.
Next time you feel stuck with VLOOKUP as the only option for looking up numbers, remember Excel offers us an embarrassment of Lookup-option riches.
Check out these comments in a Linkedin Group. Contains some overlooked functions like SUMQ, GETPIVOTDATA, SUMX2PY2, TRIMMEAN among others all of which can be used to look up numbers
DOWNLOAD SPREADSHEET AND TRY MORE OPTIONS
RELATED ARTICLES
7 OVERLOOKED USES OF EXCEL MOD FUNCTION
7 ALTERNATIVES TO NESTED IF FUNCTION
7 WAYS TO USE EXCEL REPT FUNCTION
EXCEL OUT OF BOX CREATIVITY BOOKS
The post 7+ WAYS TO LOOKUP NUMBER VALUES appeared first on CrispExcel.com.
]]>The post HLOOKUP with multiple criteria (OR/AND logic) appeared first on CrispExcel.com.
]]>To look up data horizontally, many excel users tend to use HLOOKUP but it has its limitations. So what are the alternatives?
In this article, we shall look at?
For a comprehensive look at above check out this previous article
All my attempts to use HLOOKUP to return multiple results using (OR/AND) logic failed until I discovered a combination of INDEX, SMALL, IF and ROW functions that worked like magic.
Suppose you have below attendance register and you want to look up and return all PRESENT staff on 01-07-2016.
=INDEX(Staff, SMALL( IF( (Dates=$J$3)*(Attendance=$J$4),COLUMN(Staff)-1,""), ROW(A1)))
How it Works
►First, create named ranges for easy referencing
►(Dates=$J$3) checks for 01-07-2017 among the dates and returns an array of TRUE/FALSE.
{FALSE;FALSE;FALSE;FALSE;FALSE;TRUE; FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}
►(Attendance=$J$4) checks for P in the attendance data and returns an array of TRUE/FALSE
{TRUE,FALSE,FALSE,TRUE;TRUE,TRUE,TRUE,TRUE;TRUE, TRUE,TRUE,TRUE;FALSE,FALSE,TRUE,TRUE;TRUE,TRUE, TRUE,TRUE;TRUE,FALSE,FALSE,TRUE;TRUE,TRUE,TRUE, TRUE;TRUE,TRUE,FALSE,FALSE;TRUE,TRUE,TRUE,TRUE; TRUE,TRUE,TRUE,TRUE;FALSE,FALSE,TRUE,TRUE;TRUE, TRUE,TRUE,TRUE}
► (Dates=$J$3)*(Attendance=$J$4) the two Boolean arrays are converted into their numeric equivalent of 1 & o during multiplication and then using the techniques of conjunction truth table, below numeric array is produced.
{0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0;1, 0,0,1;0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0;0,0,0 ,0;0,0,0,0}
►((Dates=$I$3)*(Attendance=$I$4))=1 checks occurrences of 1 in the above array and returns a Boolean array below
{FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE, FALSE;FALSE,FALSE,FALSE,FALSE;FALSE,FALSE, FALSE,FALSE;FALSE,FALSE,FALSE,FALSE;TRUE, FALSE,FALSE,TRUE;FALSE,FALSE,FALSE,FALSE; FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE, FALSE;FALSE,FALSE,FALSE,FALSE;FALSE,FALSE, FALSE,FALSE;FALSE,FALSE,FALSE,FALSE}
►IF((Dates=$J$3)*(Attendance=$J$4),COLUMN(Staff)-1,””) IF function returns a columns number where the criteria is TRUE else blank (“”)
=SMALL( {"","","","";"","","","";"","","","";"","","","";"", "","","";1,"","",4;"","","","";"","","","";"","","", "";"","","","";"","","","";"","","",""} ,ROW(A1) )
►The SMALL function returns the column numbers one at a time using the ROW(A1) number as its K
►The INDEX function returns the staff name given the column number by the small function.
NB:
Now, Suppose you want to look up and return the staff who were Either on Off (WO) or Leave (LV) on 01-07-2017
=INDEX(Staff, SMALL( IF( ((Dates=$J$7)*((Attendance=$J$8)+(Attendance=$J$9)))=1,COLUMN(Staff)-1,"") ,ROW(A1)))
How it Works
► This time we use a plus (+) to replace OR logic
=IF(OR(Criteria_range1=criteria1,Criteria_range2=criteria2) Does NOT return an array. Therefore, to go around this limitation use plus (+) sign
►(Dates=$L$3)*((Attendance=$L$4)+(Attendance=$L$5)) Returns an array of 0 (where no criteria were met), 1 (where the dates criterion was met and either one of the other 2 criteria were met)
{0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0;0,1 ,1,0;0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0; 0,0,0,0}
►(Dates=$L$3)*((Attendance=$L$4)+(Attendance=$L$5))=1 checks occurrences of 1 in the above array and returns a Boolean array.
►IF function returns a columns numbers where criteria are TRUE
►The SMALL function returns the column numbers one at a time using the ROW(A1) number as its K
►The INDEX function returns the staff name given the column number by the small function.
Conclusion:
This is all you need to solve horizontal lookup issues that require;
DOWNLOAD HLOOKUP WITH DUPLICATES WORKSHEET
RELATED ARTICLES
REVERSE LOOKUP WITH DUPLICATES IN EXCEL
RECOMMENDED READING
The post HLOOKUP with multiple criteria (OR/AND logic) appeared first on CrispExcel.com.
]]>