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.
 
You're welcome & thanks for the feedback.
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
One more question: is it possible within the same formula to apply some custom sorting on the filtered sheet? Let's say France data to be displayed on top, then Italy, then Spain etc., assuming there is a hierarchy. Thank you.
 
Upvote 0
If you sort the City_country list in the order you want the countries to appear, you can use
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),SORTBY(IF(s=4,x,INDEX(f,SEQUENCE(ROWS(f)),s)),MATCH(x,City_Country!B2:B100,0),1))
 
Upvote 0
If you sort the City_country list in the order you want the countries to appear, you can use
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),SORTBY(IF(s=4,x,INDEX(f,SEQUENCE(ROWS(f)),s)),MATCH(x,City_Country!B2:B100,0),1))
Thank you so much for the solution!
 
Upvote 0
Hi. Need your help again. I have now an additional sorting to apply. Keeping the hierachy by country already established, need to see the order date in descending. Is it possible? Thank you so much!
 
Upvote 0
Try
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),SORTBY(IF(s=4,x,INDEX(f,SEQUENCE(ROWS(f)),s)),MATCH(x,City_Country!B2:B100,0),1,INDEX(f,,10),-1))
 
Upvote 0
Try
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),SORTBY(IF(s=4,x,INDEX(f,SEQUENCE(ROWS(f)),s)),MATCH(x,City_Country!B2:B100,0),1,INDEX(f,,10),-1))
Perfect, thank you so much!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

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