简体   繁体   中英

How to get the related date if the company name is duplicated in google spreadsheet?

I am in the learning phase of google spreadsheet. I am trying to get the date corresponding to the company name if the company name is duplicated.

Public google sheet

Required

Company date  duplicated company date
one     jan1
two     jan1
one     feb1  jan1 (find this using some formula)
two     feb4  jan1
two     mar3  feb4 (if repeated take the previous date)
three   apr1  
four    apr5

There is no good way to do this. Especially if we don't know why we are doing this in the first place.

在此处输入图像描述

The closest I could get is using FILTER :

=IFERROR(INDEX(FILTER($B$2:$B2;$A$2:$A2=$A3);COUNTA(FILTER($B$2:$B2;$A$2:$A2=$A3)));"")

Place this in the second row of your data (the 3rd row of your table if you have headers), because it will not work for the first row. Then, you drag this formula down for all your rows.

Note:

  • A2 is where I had the first company, like "Apple"
  • B2 is where I had the first date, like "Jan 1"

You can place this formula in C3, and drag-copy to all rows beneath it using the colored square in the bottom-right corner of the cell you have highlighted.

在此处输入图像描述

(In case you didn't know)

Have fun! ^_^

I have added a code to your spreadsheet, does this fix your issue?

The code: =if((countif(B:B,B2)>1)=FALSE," ",C2)

This works for G2, for G3 you need to change "B2" to "B3" and "C2" to "C3", and so on...

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