简体   繁体   中英

Select lowest date from one column, subtract that value from a date in a separate column B, but ignore duplicates in a third column in excel

I have an Excel file with the following structure (here is a link showing the data structure if that helps): 样本数据

A B C D E

ID  PayDate PayAmount   BillDate    OriginalBillAmount

1423    1/12/15 $20.00  1/1/15  $1,000.00

1423    2/10/15 $49.00  1/1/15  $1,000.00

1423    2/12/15 $122.00 1/1/15  $1,000.00

5124    11/1/15 $49.00  1/4/15  $200.00

5124    3/4/15  $53.00  1/4/15  $200.00

2341    4/9/15  $12.00  1/6/15  $540.00

I want to calculate how long it takes for each person to make their first payment on their bill. IDs are duplicated because a single person made multiple payments on the balance of their bill.

How do I subtract the earliest PayAmount date in column B from the BillDate for each individual person in column D and return the difference in days as a number in column F? I'm trying to be able to reproduce this automatically as new data comes in, so a formula solution would be ideal. I would ideally like to have a column F that looks like this (the values are just examples):

F

Diff

11

(blank/NA)

(blank/NA)

(blank/NA)

124

96

Try this:

=IF(B2=MIN(IF(A2=$A$2:$A$7,$B$2:$B$7)),B2-D2,"")

Put in F2, Hit Ctrl-Shift-Enter as it is an array formula. Then copy down.

在此处输入图片说明

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