Return Value Based on Multiple Criteria

KMorrison12345

New Member
Joined
Aug 8, 2022
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
I have a file that lists multiple values for each item. I am trying to get the data so that each item has only one row. However, not every item has every value. I wish I could give access to the actual data but it is sensitive so I created an image to explain what result I am looking for. I am trying to avoid using certain vocabulary because I believe I have been looking to the wrong formulas to achieve this.

Essentially, for items listed in column 1 on the first sheet, they have one value per row. I would like each item to have only one row on the second sheet. However, not all items have the same value in col 2, but sometimes they do.
In the image, I would like in Sheet 2, Col 2 to list a yes or no if Sheet 1, Col 2 contains the number "2". And in Sheet 2, Col 3 to list out each number for numbers 1, 3, and 4 if they are available for an item. In the example provided, only item C has the value 4, therefore it is written out in Col 3 for item C only.

I hope this makes sense. I will be back on tomorrow morning to check.
 

Attachments

  • excel q.PNG
    excel q.PNG
    40.4 KB · Views: 27

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Assuming:
Table on Sheet1 is in A:B (A1:B1 has headers, row 2 is first data row)
Table on Sheet2 is in A:C (A1:C1 has headers, row 2 is first data row)

In Sheet2!B2, use this formula and fill down:
Excel Formula:
=IF(COUNTIFS(Sheet1!A:A,A2,Sheet1!B:B,2)>0,"Yes","No")
In Sheet2!C2, use this formula and fill down:
Excel Formula:
=TEXTJOIN(", ",TRUE,IF(ISNUMBER(MATCH(A2&"1",Sheet1!$A$1:$A$20&Sheet1!$B$1:$B$20,0)),1,""),IF(ISNUMBER(MATCH(A2&"3",Sheet1!$A$1:$A$20&Sheet1!$B$1:$B$20,0)),3,""),IF(ISNUMBER(MATCH(A2&"4",Sheet1!$A$1:$A$20&Sheet1!$B$1:$B$20,0)),4,""))

Adjust your source data range in the last formula from rows 1:20 to a larger range that encompasses all of your rows. Hopefully it's not 500,000 rows. :)
 
Upvote 0
Another option
Fluff.xlsm
ABCDEFGH
1
2a1aYes1, 3
3a2bYes1, 3
4a3cNo1, 3, 4
5b1
6b2
7b3
8c1
9c3
10c4
Sheet1
Cell Formulas
RangeFormula
G2:G4G2=IF(COUNTIFS(A:A,F2,B:B,2),"Yes","No")
H2:H4H2=TEXTJOIN(", ",,IF(($A$2:$A$10=F2)*(($B$2:$B$10=1)+($B$2:$B$10=3)+($B$2:$B$10=4)),$B$2:$B$10,""))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Assuming:
Table on Sheet1 is in A:B (A1:B1 has headers, row 2 is first data row)
Table on Sheet2 is in A:C (A1:C1 has headers, row 2 is first data row)

In Sheet2!B2, use this formula and fill down:
Excel Formula:
=IF(COUNTIFS(Sheet1!A:A,A2,Sheet1!B:B,2)>0,"Yes","No")
In Sheet2!C2, use this formula and fill down:
Excel Formula:
=TEXTJOIN(", ",TRUE,IF(ISNUMBER(MATCH(A2&"1",Sheet1!$A$1:$A$20&Sheet1!$B$1:$B$20,0)),1,""),IF(ISNUMBER(MATCH(A2&"3",Sheet1!$A$1:$A$20&Sheet1!$B$1:$B$20,0)),3,""),IF(ISNUMBER(MATCH(A2&"4",Sheet1!$A$1:$A$20&Sheet1!$B$1:$B$20,0)),4,""))

Adjust your source data range in the last formula from rows 1:20 to a larger range that encompasses all of your rows. Hopefully it's not 500,000 rows. :)
The first formula worked like a charm. The second one returns blank cells. This is the adjustment I made to match my file

=TEXTJOIN(", ",TRUE,IF(ISNUMBER(MATCH(A3,District!A:A&District!L:L,0)),1,""),IF(ISNUMBER(MATCH(A3&"6",District!A:A&District!L:L,0)),6,""),IF(ISNUMBER(MATCH(A3&"8",District!A:A&District!L:L,0)),8,""))

District is the name of the sheet I am pulling data from. I am looking for the numbers 1, 6 and/or 8 in column L
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,195
Members
453,021
Latest member
pingpong7117

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