FILTER function with replacing text

UserI

New Member
Joined
Mar 16, 2022
Messages
24
Office Version
  1. 365
Platform
  1. Windows
Hi. I have an Excel file with sales data, such as sales agent, location as city, product, quantity, customer, amount etc. With FILTER function I fetch to a new sheet the sales amount for all sales agents and certain cities across Europe. Is it possible to indicate within the formula that the city should be replaced with the country? I have a separate list with the corresponding countries for the cities. Thank you.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi. I have an Excel file with sales data, such as sales agent, location as city, product, quantity, customer, amount etc. With FILTER function I fetch to a new sheet the sales amount for all sales agents and certain cities across Europe. Is it possible to indicate within the formula that the city should be replaced with the country? I have a separate list with the corresponding countries for the cities. Thank you.
what code are you currently using and where do you store the list of countries/cities
 
Upvote 0
Hi & welcome to MrExcel.

Can you post some sample data of all relevant data, including the formula you are using.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
That website is blocked for me, as it's been reported for Phishing attacks.
 
Upvote 0
Sorry, hope this will be OK.

Sales data.xlsx
ABCDEFGHIJKLMNOP
1Sales Agent IDSales Agent NameProductLocationCustomerCustomer IDPriceOrder numberQuantityOrder dateOrder dispatchedOrder deliveredInvoice paidManagerDepartmentTotal Sale Amount
21Rory ClaytonLaptopParisElizabeth JacksonC2005000IN-123-C-00113/1/20213/2/20213/5/2021YesJaye MarquezCustomer Service5000
32Bradley HesterDesktopParisVictoria JamesC2015000IN-123-C-00213/2/20213/3/20213/6/2021YesAlfie BurrowsCustomer Service5000
43Alice BakerMobile phoneParisJane Harris C2022000IN-123-C-00313/3/20213/4/20213/7/2021YesShea WaltonCustomer Service2000
54Zachery CarlsonTabletParisPhil RamplingC2033000IN-123-C-00423/4/20213/5/20213/8/2021YesZiggy SimonsCustomer Service6000
65Isai HarrisonLaptopParisSimon CampbellC2045000IN-123-C-00513/5/20213/6/20213/9/2021YesJose WoolleyCustomer Service5000
76Mira NealDesktopParisLucas Hughes C2055000IN-123-C-00613/6/20213/7/20213/10/2021YesCali ThomasCustomer Service5000
87Trinity GreenMobile phoneParisBella DuncanC2062000IN-123-C-00713/7/20213/8/20213/11/2021YesRudi GlennCustomer Service2000
98Samara CoxTabletParisJoshua SandersonC2073000IN-123-C-00813/8/20213/9/20213/12/2021YesAston CallaghanCustomer Service3000
109Maryjane VillaLaptopParisLeighton MorinC2085000IN-123-C-00913/9/20213/10/20213/13/2021YesLoki BainCustomer Service5000
1110Ayden KaiserDesktopBerlinHolly DeckerC2095000IN-123-C-01013/10/20213/11/20213/14/2021YesKobi WadeCustomer Service5000
1211Hayden ShafferMobile phoneBerlinDean CraneC2102000IN-123-C-01133/11/20213/12/20213/15/2021YesStar RutledgeCustomer Service6000
1312Dominic RaymondTabletViennaSafiya ElliottC2113000IN-123-C-01213/12/20213/13/20213/16/2021YesBaran OrozcoCustomer Service3000
1413Urijah JenkinsLaptopViennaMacsen McmahonC2125000IN-123-C-01313/13/20213/14/20213/17/2021NoBo MuellerCustomer Service5000
1514Tia LoveLaptopViennaEmmanuella SmallC2135000IN-123-C-01413/14/20213/15/20213/18/2021NoNadia BuckleyCustomer Service5000
1615Cloe EnglishLaptopBerlinZi CoulsonC2145000IN-123-C-01513/15/20213/16/20213/19/2021NoDivine DejesusCustomer Service5000
1716Zackery MarshallLaptopBerlinIyla RichardsonC2155000IN-123-C-01623/16/20213/17/20213/20/2021NoShelly DownsSales10000
1817Luna ReedLaptopBerlinHuseyin BourneC2165000IN-123-C-01713/17/20213/18/20213/21/2021NoSiobhan BernalSales5000
1918Melanie BensonLaptopBerlinBurhan HowarthC2175000IN-123-C-01813/18/20213/19/20213/22/2021NoJan BobSales5000
2019Lucian HayesLaptopBerlinKaidan FelixC2185000IN-123-C-01913/19/20213/20/20213/23/2021NoLucca MarkhamSales5000
2120Haven NorrisLaptopBerlinMicah RowleyC2195000IN-123-C-02013/20/20213/21/20213/24/2021NoCoby FranklinSales5000
2221Xavier WadeLaptopBerlinMikolaj MarksC2205000IN-123-C-02183/21/20213/22/20213/25/2021NoBelle HannaSales40000
2322Tomas HuberLaptopRomeZaynab GrayC2215000IN-123-C-02213/22/20213/23/20213/26/2021NoWade ParkSales5000
2423Aryana RandolphTabletRomeNelson MooneyC2223000IN-123-C-02313/23/20213/24/20213/27/2021NoAda RoachSales3000
2524Jakobe OnealTabletBerlinKamal AlbertC2233000IN-123-C-02413/24/20213/25/20213/28/2021NoSkye ParkesSales3000
2625Adelyn StephensTabletBerlinCamilla GilmoreC2243000IN-123-C-02513/25/20213/26/20213/29/2021NoJorge ShepherdSales3000
2726Dale OrtizTabletBerlinMeadow McleanC2253000IN-123-C-02613/26/20213/27/20213/30/2021NoNikki GarrisonSales3000
2827Conrad DanielTabletBerlinEsme-Rose CurrieC2263000IN-123-C-02713/27/20213/28/20213/31/2021NoIra MillsSales3000
2928Raina NovakTabletBerlinDarren PrestonC2273000IN-123-C-02813/28/20213/29/20214/1/2021NoYassin MccartneySales3000
3029Kadence BarberTabletBerlinLukas FrenchC2283000IN-123-C-02913/29/20213/30/20214/2/2021NoBobbie LongSales3000
3130Salvador CookTabletBerlinKyran RhodesC2293000IN-123-C-03073/30/20213/31/20214/3/2021NoQuinn GallegosSales21000
3231Jeremiah BennettTabletBratislavaErik WeaverC2303000IN-123-C-03113/31/20214/1/20214/4/2021NoShayne LowerySales3000
3332Jake SosaTabletBratislavaAlex RodriguezC2313000IN-123-C-03214/1/20214/2/20214/5/2021NoCharli BishopSales3000
3433Josephine McknightMobile phoneBratislavaNafeesa ConnerC2322000IN-123-C-03314/2/20214/3/20214/6/2021NoNevaeh ColesSales2000
3534Billy GreerMobile phoneBratislavaEliot LangleyC2332000IN-123-C-03414/3/20214/4/20214/7/2021NoRoma EvansSales2000
3635Anabel JoyceMobile phoneBratislavaMuna CannonC2342000IN-123-C-03514/4/20214/5/20214/8/2021YesArya AdamSales2000
3736Aniya LoweryMobile phoneBratislavaAbid WaltonC2352000IN-123-C-03614/5/20214/6/20214/9/2021YesKira EstesSales2000
3837Maddison BonillaMobile phoneBratislavaKodi RawlingsC2362000IN-123-C-03714/6/20214/7/20214/10/2021YesDevon MathewsSales2000
3938Ethen FreyMobile phoneBratislavaAllison SnyderC2372000IN-123-C-03844/7/20214/8/20214/11/2021YesMacauley YatesSales8000
4039Rocco HoganMobile phoneBratislavaFraser ArmstrongC2382000IN-123-C-03914/8/20214/9/20214/12/2021YesFallon NoelSales2000
4140Luna EvansMobile phoneBratislavaLeyton TysonC2392000IN-123-C-04014/9/20214/10/20214/13/2021YesAli TysonSales2000
4241Sofia CruzMobile phoneBratislavaPrisha KirbyC2402000IN-123-C-04114/10/20214/11/20214/14/2021YesKaris MunozSales2000
4342Kaitlin KnoxMobile phoneViennaAlena DaveyC2412000IN-123-C-04214/11/20214/12/20214/15/2021YesKristi PetersSales2000
4443Gemma McphersonMobile phoneViennaLexi-Mai ChristianC2422000IN-123-C-04314/12/20214/13/20214/16/2021YesDylan ParksSales2000
4544Giancarlo FlemingMobile phoneViennaHebe ThorneC2432000IN-123-C-04414/13/20214/14/20214/17/2021YesRobbie HodgeSales2000
4645Carlo GravesMobile phoneBratislavaKaira GardinerC2442000IN-123-C-04514/14/20214/15/20214/18/2021YesCorrie MatthewsSales2000
4746Vance WebbMobile phoneBarcelonaAvneet HarringtonC2452000IN-123-C-04614/15/20214/16/20214/19/2021YesSimone HillsSales2000
4847Kamari FriedmanMobile phoneBarcelonaRuby-Mae TurnerC2462000IN-123-C-04754/16/20214/17/20214/20/2021YesDane GoldsmithSales10000
4948Carmen SchwartzMobile phoneBarcelonaThiago PateC2472000IN-123-C-04814/17/20214/18/20214/21/2021YesEzra HawesSales2000
5049Cristina HaneyMobile phoneBarcelonaChristine GarciaC2482000IN-123-C-04914/18/20214/19/20214/22/2021YesKacy RichmondSales2000
5150Payton HurstMobile phoneBarcelonaAlbie VillegasC2492000IN-123-C-05014/19/20214/20/20214/23/2021YesJett ColemanSales2000
Data


Sales data.xlsx
ABCDEFGHIJKLMNOP
1Sales Agent IDSales Agent NameProductLocationCustomerCustomer IDPriceOrder numberQuantityOrder dateOrder dispatchedOrder deliveredInvoice paidManagerDepartmentTotal Sale Amount
210Ayden KaiserDesktopBerlinHolly DeckerC2095000IN-123-C-010110-Mar-2111-Mar-2114-Mar-21YesKobi WadeCustomer Service5000
311Hayden ShafferMobile phoneBerlinDean CraneC2102000IN-123-C-011311-Mar-2112-Mar-2115-Mar-21YesStar RutledgeCustomer Service6000
415Cloe EnglishLaptopBerlinZi CoulsonC2145000IN-123-C-015115-Mar-2116-Mar-2119-Mar-21NoDivine DejesusCustomer Service5000
516Zackery MarshallLaptopBerlinIyla RichardsonC2155000IN-123-C-016216-Mar-2117-Mar-2120-Mar-21NoShelly DownsSales10000
617Luna ReedLaptopBerlinHuseyin BourneC2165000IN-123-C-017117-Mar-2118-Mar-2121-Mar-21NoSiobhan BernalSales5000
718Melanie BensonLaptopBerlinBurhan HowarthC2175000IN-123-C-018118-Mar-2119-Mar-2122-Mar-21NoJan BobSales5000
819Lucian HayesLaptopBerlinKaidan FelixC2185000IN-123-C-019119-Mar-2120-Mar-2123-Mar-21NoLucca MarkhamSales5000
920Haven NorrisLaptopBerlinMicah RowleyC2195000IN-123-C-020120-Mar-2121-Mar-2124-Mar-21NoCoby FranklinSales5000
1021Xavier WadeLaptopBerlinMikolaj MarksC2205000IN-123-C-021821-Mar-2122-Mar-2125-Mar-21NoBelle HannaSales40000
1130Salvador CookTabletBerlinKyran RhodesC2293000IN-123-C-030730-Mar-2131-Mar-213-Apr-21NoQuinn GallegosSales21000
1238Ethen FreyMobile phoneBratislavaAllison SnyderC2372000IN-123-C-03847-Apr-218-Apr-2111-Apr-21YesMacauley YatesSales8000
1347Kamari FriedmanMobile phoneBarcelonaRuby-Mae TurnerC2462000IN-123-C-047516-Apr-2117-Apr-2120-Apr-21YesDane GoldsmithSales10000
Filter
Cell Formulas
RangeFormula
A2:P13A2=FILTER(Data!A:P,(ISNUMBER(SEARCH("b",Data!D:D))*(Data!P:P>=5000)))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
Data!_FilterDatabase=Data!$A$1:$P$51A2


Sales data.xlsx
AB
1LocationCountry
2ParisFrance
3BerlinGermany
4BudapestHungary
5TczewPoland
6OsloNorway
7RomeItaly
8BratislavaSlovakia
9ViennaAustria
10BarcelonaSpain
11LisbonPortugal
City_Country
 
Upvote 0
Thanks for that.
The only way I can think of at the moment is something like
Excel Formula:
=LET(f,FILTER(Data!A:P,(ISNUMBER(SEARCH("b",Data!D:D))*(Data!P:P>=5000))),x,XLOOKUP(INDEX(f,,4),City_Country!A2:A100,City_Country!B2:B100,"",0),CHOOSE(SEQUENCE(,16),f,f,f,x,INDEX(f,,5),INDEX(f,,6)))
you will need to add the rest of the index function to the end in the same manner as I've shown
 
Upvote 0
Ignore my previous post, try this instead.
Excel Formula:
=LET(f,FILTER(Data!A:P,(ISNUMBER(SEARCH("r",Data!D:D))*(Data!P:P>=5000))),x,XLOOKUP(INDEX(f,,4),City_Country!A2:A100,City_Country!B2:B100,"",0),s,SEQUENCE(,16),IF(s=4,x,INDEX(f,SEQUENCE(ROWS(f)),s)))
 
Upvote 0
Solution
Ignore my previous post, try this instead.
Excel Formula:
=LET(f,FILTER(Data!A:P,(ISNUMBER(SEARCH("r",Data!D:D))*(Data!P:P>=5000))),x,XLOOKUP(INDEX(f,,4),City_Country!A2:A100,City_Country!B2:B100,"",0),s,SEQUENCE(,16),IF(s=4,x,INDEX(f,SEQUENCE(ROWS(f)),s)))
Thank you so much! It works perfectly!
 
Upvote 0

Forum statistics

Threads
1,215,364
Messages
6,124,507
Members
449,166
Latest member
hokjock

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