From the course: Excel Tips Weekly
Use SWITCH, IFS, and CHOOSE functions, contrasted with XLOOKUP - Microsoft Excel Tutorial
From the course: Excel Tips Weekly
Use SWITCH, IFS, and CHOOSE functions, contrasted with XLOOKUP
- [Instructor] When you're trying to look up data in Excel, sometimes you'll use a list. Sometimes you'll use it within a function. You're likely to be thinking of the XLOOKUP function or perhaps its companions, VLOOKUP and HLOOKUP, and those are powerful tools, but there are other functions as well too. And when you're trying to track these down, there might be a slight bit of confusion, at least at first. As you go to the Formulas tab in the ribbon, if you go to Lookup & Reference, you certainly will find in here, and they're alphabetical, of course, you'll see XLOOKUP at the bottom, but also a function in here called CHOOSE up top, but also a function called CHOOSE. Now the other two functions shown in the blue panel to the right are not LOOKUP functions, but yet they have a lot in common with these two functions. SWITCH and IFS are found under the category Logical. Now if you've worked with the IF function, you obviously would expect IFS to be in the same category and it is, but also the SWITCH function too. And they all have something in common in that they allow us to test for a condition and then provide an answer. And of these four, only LOOKUP requires an external table, and that's not necessarily bad. In fact, sometimes it's exactly what you want. And so in the worksheet in the background here, we've got some scores that are emerging in column F on the basis, at least initially, of XLOOKUP. So I'll double click on cell F2 here. And just a quick reminder, what we're doing here, we're looking up data in cell E2. We're looking over in column A, trying to find that. If we do find it, we go into the corresponding entry in column B. If we don't find it at all, we'll put in. in this case, a zero. Now we could put in "Not Found" if not found. We could do it that way too, if we wish. Or any other number or texts that that we might want in this situation. At the moment, it is found, but if I put in a different rating here that isn't in the list, you know, we get that, so that's pretty much self-explanatory once you see it. Now starting in row 5, I'm doing something a little bit different here, and that's pretty long and pretty lengthy, and it looks like it would be pretty tedious to set up. It's using the SWITCH function. And you can quickly see the logic here. What we're saying here is look at the data in cell E5. If it happens to be equal to the word Excellent, then we'll put in 99. If that check fails, we're going to see if it's equal to VeryGood, and if that's true, we'll put in 92, and so on and so on and so on. And when we get to the end here, we put up final comma and then whatever we want to appear, if not found, so in this case, it's zero. But here too, I could put in the phrase Not Found, but that certainly is a lot of typing to get it set up. But the big advantage, and it may not be that big, but you'll have to decide, no external table is required. Now imagine if that list in column A had 10 entries, this is really going to get tedious. What if it had 20? At some point, it becomes perhaps unthinkable, and maybe XLOOKUP is the way to go. So at different times, you might be able to think that out. And there's a third possibility here. We could be using a function called IFS, I-F-S, pretty much like SWITCH and also like the IF function, but we don't have to keep repeating, like the IF function does, the word IF. So here, just as we get started here, we're looking at cell E8. If it's equal to Excellent, we're going to put in a 99. If that doesn't work, we're going to check to see if it's equal to VeryGood, and so on and so on and so on, same general idea. At the end of this, it might be a little tricky at first. If we want to provide an answer for when that rating is not found, we put in the word TRUE, a comma, and then what it is that we do want to appear there when it's not found. So that's similar to the way the SWITCH function was using a default entry at the end there. Now we haven't seen the CHOOSE function just yet, but we've got another situation over here, making column G narrower here. Here are all the formulas, by the way, that we just saw to the left. Use that for reference later if you're looking this up. But let's say we're trying to calculate the quarters here. In this case, these are all first quarter. We see the answers over there. Second quarter, and we're using a function here not related to the others that we've seen so far, ROUNDUP. Now that's perfectly acceptable, and it might be exactly what you want, and I think it's just fine. Some people might be a little intimidated by this, and particularly if we're going to be changing our fiscal year system so that either July 1st is the beginning of the fiscal year or maybe October 1st, and there could be other options as well too. You have to finagle or work with this in a different way, but that could be acceptable. What are we seeing here, though, in row 7? The CHOOSE function. Now the CHOOSE function works only with numbers, and it works efficiently or reasonably efficiently with small numbers. What we're saying here is, let's look at the month in cell K8. Those entries can only be 1 through 12. We provide 12 different answers. If the month happens to be 1, our answer is 1. In other words, January is in the first quarter. If our answer is 2, here's our second entry over here, happens to be the second one, but that's in February. That's the first quarter. Same thing, this is for March. If it's April, then that's in the second quarter. It's the fourth entry that we see here. You get the idea. And if there's an advantage here, well, like ROUNDUP function, we did need an external table. But the other advantage would be what if we change or what if it's a different fiscal year system, and it begins in July? All we need to do here is take these entries right here, so I'll press Control + X to get rid of them and put 'em at the end, and invariably, I have to put in an additional comma or get rid of a trailing comma. So if your fiscal year begins in July, we're going to see a 1 here. But what's happening here? The month here is going to be 7. What's our seventh entry in this list? 1, 2, 3, 4, 5, 6, 7. It happens to be a 1. So you could easily adjust this, and if it began in October, a similar adjustment there too. But you can imagine if we need multiple answers or many, many answers, this isn't going to work so smoothly. But it certainly has its merits, and although it isn't really documentation, it's perhaps easier to understand than using a function like ROUNDUP. So we've seen some different examples of these functions. Going back here to the blue panel, the XLOOKUP function, which does require an external table, and is handy particularly as the table gets larger and larger and larger. It might be the only one to consider using, but also at different times, the CHOOSE function, the SWITCH function, and the IFS function.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
- 164_Percent_change_and_Goal_Seek.zip
- Ex_Files_Excel_Tips_Weekly_2018_Q2.zip
- 166_COUNT_COUNTA_and_Status_Bar.zip
- 165_Fill_in_Blanks.zip
- Ex_Files_Excel_Tips_Weekly_2018_Q3.zip
- 162_Freeze_Panes_and_Split_Screens.zip
- 203_Mixed_Cell_Addresses.zip
- 202_Worksheet_Protection.zip
- 161_Custom_Lists.zip
- 201_Error_Checking_Indicators.zip
- 205_Displaying_Large_Values.zip
- 163_NETWORKDAYS_and_WORKDAY.zip
- 204_Filter_by_Selection.zip
- 160_Date_Format_Conversions.zip
- 159_Number_Formats.zip
- 200_Linking_Pictures.zip
- 199_Charts_and_Filters.zip
- 198_Weekdays_and_Weekends.zip
- 197_Helpful_Keystroke_Shortcuts.zip
- 157_Comments_and_Reminders.zip
- 156_Date_Time_Formats.zip
- 196_Double_and_Triple_Spaced_Printing.zip
- 195_TRIM_and_CLEAN.zip
- 194_LEN_and_REPT.zip
- 158_Replace_Format_or_Content.zip
- 155_Default_Chart_Type_and_Chart_Templates.zip
- 154_Phone_and_ZipCode_Formats.zip
- 192_PivotTable_Settings.zip
- 151_Chart_gridlines_and_borders.zip
- 150_Mixed_References.zip
- 153_Expand_Collapse_PivotTables.zip
- 190_Solver.zip
- 152_INDIRECT_Intersection_RangeNames.zip
- 191_Columns_Widths.zip
- 149_Decimals_and_Fractions.zip
- 194_Watch_Window.zip
- 189_Alt_Key_Shortcuts.zip
- 123_Book1.zip
- 186_Sort_by_Moving_Columns.zip
- 185_Unintentional_Entries.zip
- 188_CONVERT_Function.zip
- 187_Cumulative_Totals.zip
- 184_Date_Calculations.zip
- 124_Quick_Charts.zip
- 183_New_Table_Style.zip
- 180_Table_Differences.zip
- 179_Date_Proximity_Formatting_final.zip
- 182_FormattingOptions.zip
- 181_Avoiding_DIV_Error.zip
- 126_INDEX_Function.zip
- 127_Display_Tips.zip
- 128_Wrap_text_Merge_Indent.zip
- 129_Fill_Effects.zip
- 125_Heat_Maps.zip
- 134_Two_Way_Lookups.zip
- 178_Adjusting_Names.zip
- 130_Multiple_Worksheets.zip
- 131_Other_Font_Options.zip
- 132_WordArt_Variations.zip
- 133_Weekday_Weekend.zip
- 175_ROMAN_ARABIC.zip
- 174_EXACT_FIND_SEARCH_Functions.zip
- 177_Customize_the_Quick_Access_Toolbar.zip
- 176_Range_Names.zip
- 135_Borders_Gridlines.zip
- 173_YEAR_MONTH_DAY_WEEKDAY.zip
- 172_Abstract_Art_with_Random_Numbers_and_Excel_Charts.zip
- 189_Chart_based_on_a_Table.zip
- 169_PivotTable_Date_Grouping.zip
- 171_Zoom_and_Display_Variations.zip
- 170_Unique_and_Duplicate_Data.zip
- 168_Ranking_Data.zip
- 167_Excel_Sheet_Commands.zip
- Ex_Files_Excel_Tips_Weekly_2018_Q1.zip
- 206_ConditionalFormatting_and_DataValidation.zip
- 207_CheckBox_ConditionalFormatting.zip
- 208_Transpose.zip
- 209_Borders_Gridlines_Printing.zip
- 210_SmartArt.zip
- 211_GoTo_Special.zip
- 212_CEILINGandFLOOR.zip
- 213_Shapes_and_Stars.zip
- 214_Array_Constants_withVLOOKUP.zip
- 215_AdvancedFilter.zip
- 216_ArrayFormulaUpdates.zip
- 217_UNIQUE_function.zip
- 218_Sample_Data.zip
- 219_Utility_Macros.zip
- 220_SORT_and_SORTBY_Functions.zip
- 221_Themes.zip
- 222_Financial_Functions.zip
- 223_BlankCellsInCharts.zip
- 224_CondFormattingBreakpoints.zip
- 225_New_Formulas.zip
- 226_Sort_by_Color.zip
- 227_Special_Characters.zip
- 228_Icons.zip
- 229_Random_Functions.zip
- 230_Area_Charts.zip
- 231_People_Graph.zip
- 232_GrowingChart.zip
- 233_ScenarioManager.zip
- 234_Status_Bar.zip
- 235_Columns_and_Rows.zip
- 236_Dates_in_Charts.zip
- 237_Geographic_Maps.zip
- 238_Date_Time_Series.zip
- 239_Data_Validation_and_Filter.zip
- 240_Find_Select.zip
- 241_AverageCountSubscript.zip
- 242_CopyFormats.zip
- 243_XLOOKUP_Function.zip
- 244_PivotTable_Settings.zip
- 245_FilterYearDay.zip
- 246_Sheet_Names.zip
- 247_Phone_ZipFormats.zip
- 248_Time_Math.zip
- 249_Prevent_Locate_Duplicates.zip
- 250_EDate_EMonth_DatedIF.zip
- 251_Find_Highlight_Formula_cells.zip
- 252_Text_Columns_Flash_Fill.zip
- 253_Cumulative_Formulas.zip
- 254_XMATCH_Function.zip
- 255_Hidden_Visible_Data.zip
- 256_Macro_Highlight_Formula_Cells.zip
- 257_TODAY_NOW_Date_Functions.zip
- 258_Prevent_Duplicates.zip
- 259_Hide_cells_rows_columns_sheets.zip
- 260_Align_Arrange_Rotate_Shapes.zip
- 261_Worksheet_Statistics.zip
- 262_Re_scaling_Column_and_Line_Charts.zip
- 263_Fill_Justify_Wrap_Text.zip
- 264_Names_Based_On_Column_Row_Headings.zip
- 265_SUBSTITUTE_and_REPLACE_Functions.zip
- 266_Buttons_for_Conditional_Formatting.zip
- 267_Wildcards_Part_1_Filter_and_Commands.zip
- 268_Wildcards_Part_2_Functions_.zip
- 269_IFS_Function.zip
- 270_Chart_Formatting_Gap_Width_Shadow_Glow_3D.zip
- 271_Protect_Cell_Ranges.zip
- 272_Geography_Data.zip
- 273_SEQUENCE_function.zip
- 274_LEN_SUBSTITUTE_and_TRIM_functions.zip
- 275_List_Box.zip
- 276_COUNT_COUNTA_and_COUNTBLANK_functions.zip
- 277_Banded_Rows_or_Columns.zip
- 278_Dragging_cells_with_Ctrl_Shift_and_Alt_Keys.zip
- 279_SWITCH_function.zip
- 280_Chart_Design_Tools.zip
- 281_PivotTable_Analysis.zip
- 282_Subtotal.zip
- 283_AGGREGATE_Function.zip
- 284_The_F9_Key.zip
- 285_XLOOKUP_XMATCH.zip
- 286_Paste_Special_Options.zip
- 287_Data_Entry_Tips.zip
- 288_LET_function.zip
- 289_Create_Worksheets_Fast.zip
- 290_MovingAverage.zip
- 291_Error_Checking_Functions.zip
- 292_Line_Wrap_and_Wrap_Text.zip
- 293_Cell_Colors_Patterns_Effects.zip
- 294_Dynamic_Arrays.zip
- 295_Fonts.zip
- 296_3D_Formulas.zip
- 297_Date_Formats.zip
- 298_Cell_Precedents.zip
- 299_Date_Controls_with_Data_Validation.zip
- 300_Managing_Duplicate_Data.zip
- 301_New_Data_Types.zip
- 302_FILTER_and_UNIQUE_functions.zip
- 303_UPPER_lower_Proper.zip
- 304_Custom_Filter.zip
- 26_01_Column_and_Bar_Charts.zip
- 26_02_Powers_and_Roots.zip
- 26_03_ISTEXT_ISNUMBER_ISNONTEXT.zip
- 26_04_Function_Names.zip
- 26_05_SUM_SUMPRODUCT_SUMIF.zip
- 26_06_Binary_Octal_Decimal_Hexadecimal.zip
- 26_07_Numeric_Formatting.zip
- 26_08_Dates_and_the_1930_2029_split.zip
- 26_09_Wildcard_lookups_XLOOKUP_and_XMATCH.zip
- 26_10_Slicers_Analysis.zip
- 26_11_Heat_Maps.zip
- 26_12_Validation_with_UNIQUE_and_SORT_functions.zip
- 26_13_Clustered_vs_Stacked_Chart_Types.zip
- 27_01_XLOOKUP.zip
- 27_02_Update_Date_Entries.zip
- 27_03_Eliminate_Spaces_and_Special_Characters.zip
- 27_04_Create_Range_Names_From_Headings.zip
- 27_05_Date_Series_Creation.zip
- 27_06_LAMBDA_Function.zip
- 27_07_Goal_Seek.zip
- 27_08_Sort_by_Custom_List.zip
- 27_09_INDIRECT_function.zip
- 27_10_Holiday_Calculations.zip
- 27_11_Paste_Special_Drag_Options.zip
- 27_12_SS_Numbers.zip
- 28_01_Five_Invaluable_Keystroke_Shortcuts.zip
- 28_02_New_Formula_Techniques.zip
- 28_03_Time_differencees.zip
- 28_04_Zoom_Techniques.zip
- 28_05_Outlining_Tools.zip
- 28_06_Analyze_Data.zip
- 28_07_UNIQUE_Unique_vs_Distinct.zip
- 28_08_Screen_Snip.zip
- 28_09_Sunburst_Charts.zip
- 28_10_Shadow_Glow_Reflection.zip
- 28_11_Printing_Tips.zip
- 29_01_Data_Validation_Multiple_Criteria.zip
- 29_02_Quick_Access_Toolbar_QAT_Tips.zip
- 29_03_Treemap_Charts.zip
- 29_04_Quick_Analysis_Button.zip
- 29_05_Dragging_Number_Cells.zip
- 29_06_Analyze_Sales_using_the_IF_MAX_and_COUNTIF_functions.zip
- 29_07_Hide_Unhide_Worksheets.zip
- 29_08_Fill_Justify_Re_wrap_text.zip
- 29_09_Date_Series_15th_and_Month_End.zip
- 29_10_Filling_Blank_Cells.zip
- 29_11_Sparklines_and_Conditional_Formatting.zip
- 29_12_Transpose.zip
- 30_01_Emojis_and_Pictures.zip
- 30_02_Advanced_Filter.zip
- 30_03_Combo_Charts.zip
- 30_04_MID_SEQUENCE_LEN_Functions.zip
- 30_05_PivotTable_Settings.zip
- 30_06_Navigation.zip
- 30_07_DATEDIF_Function.zip
- 30_08_Word_Art_Transform.zip
- 30_09_Dates_Months_Weekdays.zip
- 30_10_Linkage_Formulas.zip
- 30_11_XLOOKUP_Solutions.zip
- 30_12_TREND_and_GROWTH.zip
- 30_13_Stock_Charts.zip
- 31_01_Gridlines_On_Off.zip
- 31_02_Formulas_Changes.zip
- 31_03_Dependencies.zip
- 31_04_Replace_Formats.zip
- 31_05_Option_Buttons_and_Check_Boxes.zip
- 31_06_SORT_and_FILTER_Functions.zip
- 31_07_Moving_Average.zip
- 31_08_Data_Validation.zip
- 31_09_Picture_Links.zip
- 31_10_SUMIF_and_SUMIFS.zip
- 31_11_Multiple_PivotTables_from_one_source.zip
- 31_12_Conditional_Formatting_Icons.zip
- IMAGE_Function.zip
- 378_TOROW_and_TOCOL_functions.zip
- 379_Formulas_with_hidden_rows.zip
- 380_Bubble_charts.zip
- 381_CONCAT_TEXTJOIN_TEXTSPLIT_functions.zip
- 382_Shrink_to_fit_options.zip
- 383_Precedent_Cells.zip
- 384_Formula_editing.zip
- 385_Status_Bar_Control.zip
- 386_Sorting_Tips.zip
- 387_TEXTBEFORE_TEXTAFTER.zip
- 388_Quick_Chart_Titles.zip
- 390_TAKE_DROP_FILTER_SORTBY.zip
- 391_Pivot_Table_Detail.zip
- 392_Right_click_Filtering.zip
- 393_WRAPROWS_and_WRAPCOLS_Functions.zip
- 394_Dates_and_Times.zip
- 395_Creating_Charts_Quickly.zip
- 396_CHOOSEROWS_and_CHOOSECOLS_Functions.zip
- 397_Decimals_Rounding_Formulas.zip
- 398_Pivot_Table_Formatting.zip
- 399_DB_Functions.zip
- 400_Pie_Charts.zip
- 401_Quick_Sorting.zip
- 402_Charts_to_Pictures.zip
- 402_Tracking_Cell_Types.zip
- 403_BYROW_and_BYCOL_Functions.zip
- 404_Formula_Shortcuts.zip
- 405_3_D_Column_and_Bar_Chart.zip
- 406 _VSTACK_and_HSTACK_functions.zip
- 407_Calculating_by_Day_of_the_Week.zip
- 408_XMATCH_and_XLOOKUP.zip
- 409_Select_Cell_Ranges.zip
- 410_Inserting_Symbols.zip
- 411_Using_IS_Information_functions.zip
- 412_Using_LEFT_MID_TEXT_functions.zip
- 413_Edit_Go_To_Options.zip
- 414_Fiscal_Year_Calculations.zip
- 415_SORT_Left_Right.zip
- 416_Conditional_Formatting_Analysis.zip
- 417_Indenting.zip
- 418_FILTER_AND_OR_Functions.zip
- 419_Shapes_Linked_to_Worksheet_Cells.zip
- 420_Slicers_with_Charts.zip
- 421_Sort_by_Day_of_Month.zip
- 422_Wildcards.zip
- 423_FIND_SEARCH_COUNT_Functions.zip
- 424_Histogram_Charts.zip
- 425_AND_and_OR_Functions.zip
- 426_Flipping_Lists.zip
- 427_TEXTJOIN_CONCAT.zip
- 428_Excel_Options.zip
- 429_Alt_key_shortcuts.zip
- 430_COUNTIF_family.zip
- 431_Scatter_XY_Charts.zip
- 432_Tracking_Data_Validation.zip
- 433_AGGREGATE_Function.zip
- 434_Duplicate_Data.zip
- 435_SEQUENCE_Function.zip
- 436_Tables_Validation_XLOOKUP_Chart.zip
- 437_Stacked_Column_and_Area_Charts.zip
- 438_FILTER_SORT_and_CHOOSECOLS_functions.zip
- 440_New_Office_Theme.zip
- 441_TOCAL_LARGE_SMALL.zip
- 442_Chart_Quick_Layout_Options.zip
- 443_Display_and_Presentation_Tips.zip
- 444_WORKDAY_NETWORKDAYS_SEQUENCE.zip
- 445_Column_and_Row_References.zip
- 446_Accessibility.zip
- 447_XLOOKUP_multiple_column_return.zip
- 448_Charts_with_Filters_and_Slicers.zip
- 449_SORT_and_SORTBY_functions.zip
- 450_Navigation_Tools.zip
- 451_Using_RANK_and_LET_functions.zip
- 452_Conditional_Formatting_across_Rows.zip
- 453_PivotTable_Dates.zip
- 454_TODAY_and_NOW_Functions.zip
- 455_Freeze_and_Split.zip
- 456_Rounding_functions_CEILING_and_FLOOR.zip
- 457_Data_Bars.zip
- 458_AutoSum_Tips.zip
- 459_INDIRECT_Function.zip
- 460_Custom_Lists.zip
- 461_Split_Consolidate.zip
- 462_Subtotals.zip
- 463_Random_Functions.zip
- 464_Ten_Quick_Tips.zip
- 465_GROUPBY_and_PIVOTBY_Functions.zip
- 466_Formulas_based_on_different_worksheets.zip
- 467_Command_Locator.zip
- 468_Check_Box.zip
- 469_Paste_Values.zip
- 470_Chart_Array_SORT_FILTER.zip
- 471_Extract_data_from_picture.zip
- 472_Custom_Views.zip
- 473_PERCENTOF.zip
- 474_Navigation_Pane.zip
- 475_Shadow_Boxes.zip
- 476_Updating.zip
- 477_XLOOKUP_multiple_columns.zip
- 478_Forecast_Tool.zip
- 479_Default_Chart_Type_Chart Templates.zip
- 480_Group_Pivot_Table_Fields.zip
- 481_ISFORMULA_and_Formula_Auditing.zip
- 482_Filtering_with_Slicers.zip
- 483_TRANSPOSE.zip
- 484_Goal_Seek.zip
- 485_Repeating_Tiles.zip
- 486_SUBSTITUTE_and_REPLACE_functions.zip
- 487_Bar_Charts.zip
- 488_Selection_Pane.zip
- 489_Pivot_Table_Layouts.zip
- 490_Flash_Fill.zip
- 491_Cell_Protection_Schemes.zip
- 492_Number_Formats.zip
- 493_3D_Models.zip
- 494_COUNT_COUNTA_COUNTBLANK_ISBLANK.zip
- 495_PMT_and_FV_Functions.zip
- 496_GROUPBY_Function.zip
- 497_Check_Box_Conditional_Formatting.zip
- 498_Time_Math.zip
- 499_Alt_Key_Shortcuts.zip
- 500_PIVOTBY_Function.zip
- 501_Focus_Feature.zip
- 502_Custom_Lists.zip
- 503_Dragging_Techniques.zip
- 504_TRIMRANGE_and_new_address_symbol.zip
- 505_Shapes.zip
- 506_XMATCH_and_INDEX.zip
- 507_Files_Options_General_Settings.zip
- 508_SEQUENCE_Function.zip
- 509_Borders_Gridlines.zip
- 510_Database_Functions.zip
- 511_TAKE_Function.zip
- 512_Hidden_Visible_Data.zip
- 513_TRANSLATE_and_STCTLANGUAGE.zip
- 514_PivotTable_Time_based_Grouping.zip
- 515_FIND_MID_TEXTAFTER_TEXTBEFORE_Functions.zip
- 516_2_digit_Year_Displays.zip
- 517_Multi_worksheet_Formulas.zip
- 518_Advanced_Filter.zip
- 519_Titles_linked_to_Charts_and_Shapes.zip
- 520_EOMONTH_EDATE.zip
- 521_Analyze_Data.zip
- 522_PageBreakPreview.zip
- 523_Time_Math.zip.zip
- 524_Chart_Efficiency.zip
- 525_PivotTable_Consolidation.zip
- 526_UNIQUE_and_FILTER_functions.zip
- 527_TEXTSPLIT.zip
- 528_List_and_Combo_Boxes.zip
- 529_Information_Functions.zip
- 530_Go_To_Special.zip
- 531_Right_to_Left_Sorting.zip
- 532_Auto_Outline.zip
- 533_SWITCH_IFS_CHOOSE_Functions.zip