Complex IF Statement

%3CLINGO-SUB%20id%3D%22lingo-sub-2102588%22%20slang%3D%22en-US%22%3EComplex%20IF%20Statement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2102588%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22zkussad_0-1611766679931.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F249871i208E4548718FAE3D%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22zkussad_0-1611766679931.png%22%20alt%3D%22zkussad_0-1611766679931.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EHello%2C%20I%20have%20an%20excel%20sheet%20I%20am%20setting%20up%20to%20use%20for%20my%20budget.%20I%20was%20wondering%20if%20there%20was%20a%20way%20to%20use%20IF%20functions%20to%20have%20the%20%22Category%22%20column%20determined%20by%20the%20description%20in%20column%20D.%20I%20go%20to%20the%20same%20places%20often%2C%20so%20I%20was%20hoping%20to%20be%20able%20to%20just%20enter%20the%20name%20of%20the%20restaurant%20and%20have%20it%20auto-populate%20in%20Column%20E%20as%20%22Restaurant%22.%20Also%20willing%20to%20try%20solutions%20outside%20of%20the%20IF%20function%20is%20there%20is%20a%20better%20way.%20Thanks%20in%20advance.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2102588%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2103353%22%20slang%3D%22en-US%22%3ERe%3A%20Complex%20IF%20Statement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2103353%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F944911%22%20target%3D%22_blank%22%3E%40zkussad%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECreate%20a%20separate%20list%20or%20table%20with%20unique%20descriptions%20in%20the%20first%20column%20and%20the%20the%20corresponding%20category%20in%20the%20second%20column.%20Let's%20say%20that%20this%20list%20is%20in%20K2%3AL50.%3C%2FP%3E%0A%3CP%3EClear%20column%20E%20in%20the%20table%20(from%20E2%20down).%3C%2FP%3E%0A%3CP%3EEnter%20the%20following%20formula%20in%20E2%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DIFERROR(VLOOKUP(%5B%40Description%5D%2C%24K%242%3A%24L%2450%2C2%2CFALSE)%2C%22%22)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EExcel%20should%20automatically%20extend%20the%20formula%20to%20all%20rows%20of%20the%20table.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

zkussad_0-1611766679931.png

Hello, I have an excel sheet I am setting up to use for my budget. I was wondering if there was a way to use IF functions to have the "Category" column determined by the description in column D. I go to the same places often, so I was hoping to be able to just enter the name of the restaurant and have it auto-populate in Column E as "Restaurant". Also willing to try solutions outside of the IF function is there is a better way. Thanks in advance.

3 Replies

@zkussad 

Create a separate list or table with unique descriptions in the first column and the the corresponding category in the second column. Let's say that this list is in K2:L50.

Clear column E in the table (from E2 down).

Enter the following formula in E2:

 

=IFERROR(VLOOKUP([@Description],$K$2:$L$50,2,FALSE),"")

 

Excel should automatically extend the formula to all rows of the table.

@zkussad 

More 'smoke and mirrors'.

The missing categories are created by a formula in an almost hidden column.

I prefer XLOOKUP to the INDEX/MATCH but that requires Office 365.

image.png

@Peter Bartholomew I like your idea but think you should reverse it so the ENTRY is in the 'hidden' column and the formula is in the shown column (but should be locked) and then the formula would show the manual entry in the FALSE case.  In this way all the data is in the same column not just visually look like it is there:

final look                                   showing actual entries

mtarler_2-1611844278428.png             mtarler_1-1611843846697.png

I also used an alternative on the formula so that it would find an ENTRY anywhere on the list (i.e. if the first entry was blank it can find a later entry to fill in the spot.  I think this could be important especially if the list was to get re-sorted based on other criteria or just to be able to sort based on Category.

 

=IF([@[ Entry]]="",IFERROR(INDEX([ [ Entry] ],AGGREGATE(16,6,1/(([@Description]=[Description])*([ [ Entry] ]<>""))*(ROW([Description])-ROW(Table1[#Headers])),1)),""),[@[ Entry]])