简体   繁体   中英

Excel 'VLOOKUP', 'INDEX', and 'MATCH'

Okay so I was wondering if it would be possible to do an INDEX + MATCH combo to get the data from the bottom table to the top table with the states going across horizontally. I need to take the code and state so then I can place the Amount and match them to the top table. Any help or advice is appreciated.

Code    Description                                 ID       Alabama    Alaska  Arizona Arkansas    California  Colorado
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100                       
1A      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                       
1B      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                       
1C      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                       
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103                       
3       ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
3A      ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
3B      ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
4       ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4A      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4B      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4C      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       


Code    Description                                 ID      State       Amount              
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Alabama     $11.00              
1A      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Alaska      $206.00             
1B      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   California  $206.00             
1C      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Colorado    $1,726.00               
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103   Alabama     $346.00             
3       ANESTHESIA RECONSTRUCTION OF EYELID         00103   Arkansas    $85.00              
3A      ANESTHESIA RECONSTRUCTION OF EYELID         00103   California  $88.00              
3B      ANESTHESIA RECONSTRUCTION OF EYELID         00103   Colorado    $67.00              
4       ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alaska      $80.00              
4A      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   California  $62.00              
4B      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alaska      $78.00              
4C      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alabama     $73.00              

So to give some what of an example I would want it to look something like this.

Code    Description                                 ID       Alabama    Alaska  Arizona Arkansas    California  Colorado
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100    11.00                
1A      ANESTHESIA SALIVARY GLAND PROCEDURES        00100              206.00        
1B      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                                           206.00        
1C      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                                                      1726.00                   
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103                       
3       ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
3A      ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
3B      ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
4       ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4A      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4B      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4C      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       


Code    Description                                 ID      State       Amount              
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Alabama     $11.00              
1A      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Alaska      $206.00             
1B      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   California  $206.00             
1C      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Colorado    $1,726.00               
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103   Alabama     $346.00             
3       ANESTHESIA RECONSTRUCTION OF EYELID         00103   Arkansas    $85.00              
3A      ANESTHESIA RECONSTRUCTION OF EYELID         00103   California  $88.00              
3B      ANESTHESIA RECONSTRUCTION OF EYELID         00103   Colorado    $67.00              
4       ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alaska      $80.00              
4A      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   California  $62.00              
4B      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alaska      $78.00              
4C      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alabama     $73.00 

Edit: this is a little closer to what my spreadsheet has on it.

Code    Description                                 ID       Alabama    Alaska  Arizona Arkansas    California  Colorado
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100    11.00                                  20.00       50.00           
1A      ANESTHESIA SALIVARY GLAND PROCEDURES        00100              206.00        
1B      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                                           206.00        
1C      ANESTHESIA SALIVARY GLAND PROCEDURES        00100                                                      1726.00                   
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103    200.00    100.00                                  346.00 
3       ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
3A      ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
3B      ANESTHESIA RECONSTRUCTION OF EYELID         00103                       
4       ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4A      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4B      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104                       
4C      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104 




Code    Description                                 ID      State       Amount              
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Alabama     $11.00
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100   California  $20.00  
1       ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Colorado    $50.00          
1A      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Alaska      $206.00             
1B      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   California  $206.00             
1C      ANESTHESIA SALIVARY GLAND PROCEDURES        00100   Colorado    $1,726.00               
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103   Alabama     $200.00
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103   Colorado    $346.00 
2       ANESTHESIA FOR RECONSTRUCTION OF EYELID     00103   Alaska      $100.00           
3       ANESTHESIA RECONSTRUCTION OF EYELID         00103   Arkansas    $85.00              
3A      ANESTHESIA RECONSTRUCTION OF EYELID         00103   California  $88.00              
3B      ANESTHESIA RECONSTRUCTION OF EYELID         00103   Colorado    $67.00              
4       ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alaska      $80.00              
4A      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   California  $62.00              
4B      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alaska      $78.00              
4C      ANESTHESIA FOR ELECTROCONVULSIVE THERAPY    00104   Alabama     $73.00  

The price can change depending on the state, I hope this makes since.

Is this what you're looking for? Like you said, it's an INDEX MATCH which you can copy over and down for each state horizontally. It checks the code, checks the state at the top, and if they match it brings in the amount (otherwise a blank).

=IF(INDEX($D$17:$D$28, MATCH($A2, $A$17:$A$28, 0)) = D$1, INDEX($E$17:$E$28, MATCH($A2, $A$17:$A$28, 0)), "")

在此处输入图片说明

Edit: I see the issue outlined below where Code & State is not necessarily unique. We will FORCE a unique ID by concatenating Code, ID, and State (I am making the assumption that a code, ID, and State must return a unique result, otherwise I think something is fishy in your underlying data if it can return 2 different amounts!). Create another column on the second table that the concatenation of code, ID and state (literally, =CONCATENATE(A17, C17, D17) - although you may want to put a separator between them just for visibility, I'll use underscore in my screenshot). Then, on the upper column, change your lookup to point to the new column and concatenate the state with the ID, like so:

=IFERROR(INDEX($F$17:$F$28, MATCH($A2&"_"&$C2&"_"&D$1, $E$17:$E$28, 0)), "")

Which gets the same results as the screenshot above, except your data will look more like:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM