简体   繁体   English

使用 excel 查找范围数据的 Vlookup

[英]Vlookup using excel for range data

I have two excel files, I want to perform vlookup and find difference of costs using excel.我有两个 excel 文件,我想使用 excel 执行 vlookup 并查找成本差异。

My files look like this我的文件看起来像这样

source_data.xlsx contains contains distance covered and their price, example distance range from 1 to 100 should be charged 4800 and distance range from 101 to 120 should be charged 5100. source_data.xlsx 包含所覆盖的距离及其价格,例如从 1 到 100 的距离范围应收费 4800,从 101 到 120 的距离范围应收费 5100。

DISTANCE     COST    
1-100        4800
101-120      5100    
121-140      5500    
141-160      5900    
161-180      6200    
181-200      6600    
210-220      6900   
221-240      7200

Analysis.xlsx分析.xlsx

loading_station  distance_travel     total_cost    status    
PUGU                  40                4000       PAID        
PUGU                  80                3200       PAID    
MOROGORO              50                5000       PAID    
MOROGORO              220               30400      PAID    
DODOMA                150               5100       PAID   
KIGOMA                90                2345       PAID   
DODOMA                230               6000       PAID    
DODOMA                180               16500      PAID    
KIGOMA                32                3000       PAID    
DODOMA                45                6000       PAID   
DODOMA                65                5000       PAID    
KIGOMA                77                1000       PAID    
KIGOMA                90                4000       PAID

Actual Cost for distance is given in source_data.xlsx, I want to check cost in Analysis.xlsx if it correspond to Actual value, I want to detect underpayment and overpayment.距离的实际成本在 source_data.xlsx 中给出,我想在 Analysis.xlsx 中检查成本是否对应于实际值,我想检测支付不足和多付。

Desired Output should be like this, with two column added, source_cost which is taken from source_xlsx by using vlookup and difference which is difference between total_cost and source_cost所需的 Output 应该是这样的,添加了两列,source_cost 是使用 vlookup 从 source_xlsx 中获取的,而差异是 total_cost 和 source_cost 之间的差异

loading_station distance_travel total_cost  status  source_cost Difference    
PUGU               40                4000     PAID     4800        -800    
PUGU               80                3200     PAID     4800        -1600    
MOROGORO           50                5000     PAID     4800         200    
MOROGORO           220               30400    PAID     6900         23500    
DODOMA             150               5100     PAID     5900         -800    
KIGOMA             90                2345     PAID     4800         -2455   
DODOMA             230               6000     PAID     7200         -1200   
DODOMA             180               16500    PAID     6200          10300
KIGOMA             32                3000     PAID     4800          -1800
DODOMA             45                6000     PAID     4800           1200 
DODOMA             65                5000     PAID     4800           200   
KIGOMA             77                1000     PAID     4800           -3800  
KIGOMA             90                4000     PAID     4800           -800

Try this:尝试这个:

Vlookup(B40,$A$2:$B$8,2,1)

This assumes the distance/cost is in the table A2:B8, and the first cost to be found based on distance given is in B40.这假设距离/成本在表 A2:B8 中,并且基于给定距离找到的第一个成本在 B40 中。

But why do you get a result of 4000 for a distance of 40, when your table of distance/cost (analysis) shows anything 1 to 100 is 4800?但是,当您的距离/成本(分析)表显示 1 到 100 的任何值都是 4800 时,为什么距离为 40 的结果为 4000?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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