Formula - Based on position of one specific value within a subset

Jqarga

New Member
Joined
Dec 20, 2018
Messages
10
Hi guys,

Very specific query for a workbook I'm building so I hope you can help me.

I need to incorporate a formula in column D(Flag) so this field populates one of these three labels (First time, Prior, Before) when the following scenarios occur.

The logic/formula needs to be reset every time a new entity appears in column A:
  • Populates "First time" when "Y" appears for the first time in the Release column
  • Populates "After" to everything that happens after the first time that "Y" appears in the Release column
  • Populates "Before" for everything that happens before the first time that "Y" appears in the Release column
Sample below:

NamePeriodReleaseFlag
Entity 1
1​
NPrior
Entity 1
2​
YFirst time
Entity 1
3​
YAfter
Entity 2
1​
YFirst time
Entity 2
2​
YAfter
Entity 2
3​
NAfter
Entity 2
4​
NAfter
Entity 2
5​
YAfter
Entity 3
1​
NPrior
Entity 3
2​
NPrior
Entity 3
3​
NPrior
Entity 3
4​
YFirst Time
Entity 3
5​
NAfter


Many thanks,

JG
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I started with this to find a pattern
=COUNTIFS($A$2:A2,A2,$C$2:C2,"Y")
and noticed 0 was always prior, >1 was always after, 1 was either first time or after. This long formula returns the correct flag. Assumes Name is in A1.
=IF(COUNTIFS($A$2:A2,A2,$C$2:C2,"Y")=0,"Prior",IF(COUNTIFS($A$2:A2,A2,$C$2:C2,"Y")>1,"After",IF(AND(COUNTIFS($A$2:A2,A2,$C$2:C2,"Y")=1,C2="N"),"After","First time")))
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top