Populating Result Based on Criteria

kumara_faith

Well-known Member
Joined
Aug 19, 2006
Messages
922
Office Version
  1. 365
Hi,

I have the data in Table 1 below which shows employee numbers by month:

Book1
CDEFGHI
1Table 1
2DecJanFebMarAprMayJun
3123457123457123457123457123457123457123457
4123458123458123458123458123458123458123458
5123459123459123459123459123459123459123459
6123460123460123460123460123460123460123460
7123461123461123461123461123461123461123461
8123462123462123462123462123462123462123462
9123463123463123463123463123463123463123463
10123464123464123464123464123464123464123464
11123465123465123465123465123465123465123465
12123466123466123466123466123466123466123466
13123467123467123467123467123467123467123467
14123468123468123468123468123468123468123468
15123469123469123469123469123469123469123469
16123470123470123470123470123470123470123470
17123471123471123471123471123471123471123471
18123472123472123472123472123472123472
19123473123473123473123473123473123473
20123474123474123474123474123474123474
21123475123475123475123475123475123475
22123476123476123476123476123476123476
23123477123477123477123477123477123477
24123478123478123478123478123478123478
25123479
Sheet1



In Table 2 below, I am trying to populate the employee numbers that left the company with a minus sign at the front of employee ID and employee that joined the company without a minus sign at the front of the ID. The correct result is as below:
Book1
MNOPQR
1Table 2
2JanFebMarAprMayJun
3-123477-123476-123475-123474-123473-123472
4123478123479
5
6
Sheet1



Is there a formula that I could use for the above ? Appreciate all the help. Thanks
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I don't understand why you would record the new joiner for January in February, while recording the new joiner for May in May?

Otherwise, try
Excel Formula:
=CHOOSE({1;2},IFERROR(-FILTER(C3:C25,(COUNTIFS(D3:D25,C3:C25)=0)*(C3:C25<>""),""),""),FILTER(D3:D25,(COUNTIFS(C3:C25,D3:D25)=0)*(D3:D25<>"")*(COUNTIFS(B3:B25,D3:D25)=0),""))
in M3.
 
Upvote 0
Hi Anonynous,

My apologies. You are correct and the new joiner or resigned staff should be recognized in each month. I forgot to mention one other criteria which is that the new joiner should not repeated in the results. I added 123479 for the month of Jan and realized that the formula shows 123479 for Jan and also for May. Is there any way to ensure the new joiner is not repeated ? Appreciate all the help.

Book1
CDEFGHI
1Table 1
2DecJanFebMarAprMayJun
3123457123457123457123457123457123457123457
4123458123458123458123458123458123458123458
5123459123459123459123459123459123459123459
6123460123460123460123460123460123460123460
7123461123461123461123461123461123461123461
8123462123462123462123462123462123462123462
9123463123463123463123463123463123463123463
10123464123464123464123464123464123464123464
11123465123465123465123465123465123465123465
12123466123466123466123466123466123466123466
13123467123467123467123467123467123467123467
14123468123468123468123468123468123468123468
15123469123469123469123469123469123469123469
16123470123470123470123470123470123470123470
17123471123471123471123471123471123471123471
18123472123472123472123472123472123472
19123473123473123473123473123473123473
20123474123474123474123474123474123474
21123475123475123475123475123475123475
22123476123476123476123476123476123476
23123477123477123477123477123477123477
24123478123478123478123478123478123478
25123479123479123479
Sheet1 (2)


Book1
MNOPQR
1Table 2
2JanFebMarAprMayJun
3-123477-123476-123475-123474-123473-123472
4123479123479
Sheet1 (2)
Cell Formulas
RangeFormula
M3:R4M3=CHOOSE({1;2},IFERROR(-FILTER(C3:C25,(COUNTIFS(D3:D25,C3:C25)=0)*(C3:C25<>""),""),""),FILTER(D3:D25,(COUNTIFS(C3:C25,D3:D25)=0)*(D3:D25<>"")*(COUNTIFS(B3:B25,D3:D25)=0),""))
Dynamic array formulas.
 
Upvote 0
Hi Anonymous,

Please ignore my earlier post. New joiner staff number will repeat on all months after they join until they resign as below. I realized that if 123478 and 123479 resigned and left in June 2023, the formula returns as N/A instead in June as below. In addition, 123478 is also not showing in the results for Jan.Appreciate your help:

Book1
CDEFGHI
1Table 1
2DecJanFebMarAprMayJun
3123457123457123457123457123457123457123457
4123458123458123458123458123458123458123458
5123459123459123459123459123459123459123459
6123460123460123460123460123460123460123460
7123461123461123461123461123461123461123461
8123462123462123462123462123462123462123462
9123463123463123463123463123463123463123463
10123464123464123464123464123464123464123464
11123465123465123465123465123465123465123465
12123466123466123466123466123466123466123466
13123467123467123467123467123467123467123467
14123468123468123468123468123468123468123468
15123469123469123469123469123469123469123469
16123470123470123470123470123470123470123470
17123471123471123471123471123471123471123471
18123472123472123472123472123472123472
19123473123473123473123473123473123473
20123474123474123474123474123474123474
21123475123475123475123475123475123475
22123476123476123476123476123476123476
23123477123477123477123477123477123477
24123478123478123478123478123478
25123479123479123479123479123479
Sheet1 (2)


Book1
MNOPQR
1Table 2
2JanFebMarAprMayJun
3-123477-123476-123475-123474-123473-123472
4123479
5#N/A
Sheet1 (2)
Cell Formulas
RangeFormula
R3:R5,M3:Q4M3=CHOOSE({1;2},IFERROR(-FILTER(C3:C25,(COUNTIFS(D3:D25,C3:C25)=0)*(C3:C25<>""),""),""),FILTER(D3:D25,(COUNTIFS(C3:C25,D3:D25)=0)*(D3:D25<>"")*(COUNTIFS(B3:B25,D3:D25)=0),""))
Dynamic array formulas.



Correct Result:

Book1
MNOPQR
1Table 2
2JanFebMarAprMayJun
3-123477-123476-123475-123474-123473-123472
4123478-123478
5123479-123479
Sheet1 (3)
 
Last edited:
Upvote 0
I didn't have access to 365 at the time of answering your question, so I used CHOOSE() as a substitute for VSTACK, which did not go that well. Try this:
Excel Formula:
=VSTACK(IFERROR(-FILTER(C3:C25,(COUNTIFS(D3:D25,C3:C25)=0)*(C3:C25<>""),""),""),FILTER(D3:D25,(COUNTIFS(C3:C25,D3:D25)=0)*(D3:D25<>"")*(COUNTIFS(B3:B25,D3:D25)=0),""))
 
Upvote 0
Solution
Hi Anonymous,

Thank you for your solution and that worked. Appreciate it and have a great day ahead.
 
Upvote 0

Forum statistics

Threads
1,215,416
Messages
6,124,774
Members
449,187
Latest member
hermansoa

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