Formula to check occurances in a column based on multiple criteria

chrisou

New Member
Joined
Sep 18, 2022
Messages
5
Office Version
  1. 2013
Platform
  1. Windows
Hi Guys

I am trying to find a formula in column C of the attached spreadsheet to return a value of 1 or 2 based on whether an occurance has already happened for that day or not.
As explained in column D, if the format (Bol, Gn 1:3 or verrines) is the first series of that day, then a value of 1 should be returned.

However, on the 3 June there are 2 series of the format Bol and Verrines. In this case, I would like the formula to enter in column C a 1 for the first series and a 2 when the second series of those 2 formats were run.

The formula needs to make reference to the day and check the previous formats in column B before allocating a 1 or 2 in column C

Many thanks for your help
 

Attachments

  • simplified data.jpg
    simplified data.jpg
    241.5 KB · Views: 11

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi, chrisou!

The way I have done this, you will need a "helper column" (a column strictly to do calculations but can be hidden in your sheet) for each format changeover you have. You can have as many of them as you need, but you need to make an additional helper column for each. The formula in Column C is a nested IF statement, and there is a limit to the number of IF statements you can have without concatenating them with a &. (At least in older versions of Excel.) But you can have at least 7 different changeovers without having any problems. (I know that for sure.)
Blank.xlsb
ABCDEFG
1DateFormat ChangeoverFormat frequency
21/6/2021GN 1/31New Day100
31/6/2021GN 1/31 100
41/6/2021BOL 1301 110
51/6/2021BOL 1301 110
61/6/2021VERRINES1 111
71/6/2021VERRINES1 111
81/6/2021VERRINES1 111
92/6/2021BOL 1301New Day010
102/6/2021BOL 1301 010
113/6/2021BOL 1301New Day010
123/6/2021BOL 1301 010
133/6/2021BOL 1301 010
143/6/2021VERRINES1 011
153/6/2021VERRINES1 011
163/6/2021BOL 1302 021
173/6/2021BOL 1302 021
183/6/2021BOL 1302 021
193/6/2021VERRINES2 022
203/6/2021VERRINES2 022
214/6/2021BOL 1301New Day010
224/6/2021BOL 1301 010
234/6/2021BOL 1301 010
Series
Cell Formulas
RangeFormula
C2:C23C2=IF(B2="GN 1/3",E2,IF(B2="BOL 130",F2,IF(B2="VERRINES",G2,"?")))
D2:D23D2=IF(A1<>A2,"New Day","")
E2:E23E2=IF(D2="New Day",IF(B2="GN 1/3",1,0),IF(AND(B1<>B2,B2="GN 1/3"),E1+1,E1))
F2:F23F2=IF(D2="New Day",IF(B2="BOL 130",1,0),IF(AND(B1<>B2,B2="BOL 130"),F1+1,F1))
G2:G23G2=IF(D2="New Day",IF(B2="VERRINES",1,0),IF(AND(B1<>B2,B2="VERRINES"),G1+1,G1))

I put it to display a "?" in column C should it not recognize the changeover name. (For user-friendliness.)

Let me know if this is what you wanted. Thanks!
 
Upvote 0
Welcome to the MrExcel board!

See if this does what you want directly.

22 09 19.xlsm
ABC
1DateFormat ChangeoverFormat frequency
21/06/2021GN 1/31
31/06/2021GN 1/31
41/06/2021BOL 1301
51/06/2021BOL 1301
61/06/2021VERRINES1
71/06/2021VERRINES1
81/06/2021VERRINES1
92/06/2021BOL 1301
102/06/2021BOL 1301
113/06/2021BOL 1301
123/06/2021BOL 1301
133/06/2021BOL 1301
143/06/2021VERRINES1
153/06/2021VERRINES1
163/06/2021BOL 1302
173/06/2021BOL 1302
183/06/2021BOL 1302
193/06/2021VERRINES2
203/06/2021VERRINES2
214/06/2021BOL 1301
224/06/2021BOL 1301
234/06/2021BOL 1301
1 or 2
Cell Formulas
RangeFormula
C2:C23C2=IF(AND(A2=A1,B2=B1),C1,1+(COUNTIFS(A$1:A1,A2,B$1:B1,B2)>0))
 
Upvote 0
Solution
Hi Cmowla & Peter

Many thanks to both of you for your proposals which both work perfectly. Thank you & well done

Chris
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,216
Messages
6,123,669
Members
449,114
Latest member
aides

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