filter multiple columns at the same time

INN

Board Regular
Joined
Feb 3, 2021
Messages
118
Office Version
  1. 365
Platform
  1. Windows
Hi, I want to filter column "StoreA" by "agent1" to see which customers helped by agent1 but at the same time I still want to see which customers agent1 helped in StoreB and StoreC. Now if I filter Store A column by agent1, then I wont see which customers he/she helped in storeB and StoreC. I can filter all columns by agent1 without going to individuals columns one by one? Thank you very much.

customer NameStore AStore BStore C
Maryagent1agent2agent3
Alexagent1agent2agent4
Samagent2agent2agent5
Timagent3agent2agent1
Johnagent1agent2agent2
Annaagent1agent3agent3
Tonyagent3agent3agent4
Bobagent4agent1agent2
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
With Power Query Unpivot your data and then filter out all agents except Agent 1

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"customer Name", type text}, {"Store A", type text}, {"Store B", type text}, {"Store C", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"customer Name"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] = "agent1"))
in
    #"Filtered Rows"

Book3
ABCDEFGH
1customer NameStore AStore BStore Ccustomer NameAttributeValue
2Maryagent1agent2agent3MaryStore Aagent1
3Alexagent1agent2agent4AlexStore Aagent1
4Samagent2agent2agent5TimStore Cagent1
5Timagent3agent2agent1JohnStore Aagent1
6Johnagent1agent2agent2AnnaStore Aagent1
7Annaagent1agent3agent3BobStore Bagent1
8Tonyagent3agent3agent4
9Bobagent4agent1agent2
Sheet1
 
  • Like
Reactions: INN
Upvote 1
Solution
Check these formulas:
Dante Amor
ABCDEFGHI
1customer NameStore AStore BStore Ccustomer NameStore AStore BStore C
2Maryagent1agent2agent3Maryagent1agent2agent3
3Samagent2agent2agent5Timagent3agent2agent1
4Jimagent5agent2agent3Johnagent1agent2agent2
5Timagent3agent2agent1Annaagent1agent3agent3
6Johnagent1agent2agent2Bobagent4agent1agent2
7Annaagent1agent3agent3Alexagent1agent2agent4
8Tonyagent3agent3agent4    
9Bobagent4agent1agent2    
10Carlosagent6agent3agent4    
11Alexagent1agent2agent4    
12Danielagent6agent3agent4    
Hoja1
Cell Formulas
RangeFormula
F2:F12F2=IFERROR(INDEX($A$2:$A$12, SMALL(IF($B$2:$D$12="agent1", ROW($A$2:$A$12)),ROWS($E$2:E2))-ROW($A$2)+1),"")
G2:I12G2=IFERROR(VLOOKUP($F2,$A$2:$D$12,COLUMNS($F$1:G1),0),"")
Press CTRL+SHIFT+ENTER to enter array formulas.


Or this macro:
VBA Code:
Sub SortAgent()
  Dim a As Variant, b As Variant
  Dim i&, j&, k&, m&
  a = Range("A2", Range("D" & Rows.Count).End(3)).Value
  ReDim b(1 To UBound(a, 1), 1 To UBound(a, 2))
  
  For i = 1 To UBound(a, 1)
    For j = 2 To UBound(a, 2)
      If LCase(a(i, j)) = "agent1" Then
        k = k + 1
        For m = 1 To UBound(a, 2)
          b(k, m) = a(i, m)
        Next
        Exit For
      End If
    Next
  Next
  Range("F2").Resize(k, UBound(b, 2)).Value = b
End Sub

Since I see you have 365, maybe someone will help us with the formula.
 
  • Like
Reactions: INN
Upvote 1
Another formula option
Fluff.xlsm
ABCDEFGHIJ
1customer NameStore AStore BStore C
2Maryagent1agent2agent3agent1Maryagent1agent2agent3
3Alexagent1agent2agent4Alexagent1agent2agent4
4Samagent2agent2agent5Timagent3agent2agent1
5Timagent3agent2agent1Johnagent1agent2agent2
6Johnagent1agent2agent2Annaagent1agent3agent3
7Annaagent1agent3agent3Bobagent4agent1agent2
8Tonyagent3agent3agent4
9Bobagent4agent1agent2
10
Data
Cell Formulas
RangeFormula
G2:J7G2=FILTER(A2:D9,MMULT(--(B2:D9=F2),SEQUENCE(COLUMNS(B1:D1),,,0)))
Dynamic array formulas.
 
  • Like
Reactions: INN
Upvote 2
Thank you all for the help. I appreciate it. Thanks again.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,371
Messages
6,124,529
Members
449,169
Latest member
mm424

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