Find out how many different places are visited by each salesperson within a period (date range)

mukulesh

New Member
Joined
Feb 19, 2018
Messages
11
I have a table showing different sales persons visiting different places and their period of stay in those places. Now, I want to find out which salespersons visited more than one city within a given range of dates. Sample sheet has been attached. My results should look like the cells colored in 'green' (i.e. in the range: H2:N2)

Thanks in advance.

Sample.xlsx
ABCDEFGHIJKLMN
1NamePlaceArrival DateDeparture DatePeriod FromPeriod ToDavisHenryJohnKateMitchelNaomiPeter
2PeterLondon01-02-202103-02-202101-02-202128-02-2021YesNoNoYesYesNoNo
3DavisKairo04-02-202107-02-2021
4NaomiNew York02-01-202106-01-2021
5HenryLondon03-01-202105-01-2021
6KateSingapore12-01-202117-01-2021
7DavisDubai10-02-202112-02-2021
8PeterParis15-01-202119-01-2021
9KateNew Delhi05-02-202108-02-2021
10JohnDubai04-05-202108-05-2021
11MitchelLondon18-02-202121-02-2021
12HenryParis07-01-202112-01-2021
13NaomiNew Delhi08-01-202115-01-2021
14PeterLondon24-02-202128-02-2021
15MitchelDubai23-02-202124-02-2021
16MitchelLondon26-02-202128-02-2021
17NaomiSingapore12-02-202116-02-2021
18KateNew Delhi21-02-202125-02-2021
19HenryParis15-01-202120-01-2021
20DavisLondon25-02-202128-02-2021
21KateDubai12-02-202118-02-2021
Sheet1
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
If you use Power Query, the following will generate a report that shows who travelled during that time frame and if they visited more than one city.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Arrival Date", type date}, {"Departure Date", type date}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Arrival Date] >= #date(2021, 2, 1) and [Arrival Date] <= #date(2021, 2, 28)),
    #"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each [Departure Date] >= #date(2021, 2, 1) and [Departure Date] <= #date(2021, 2, 28)),
    #"Grouped Rows" = Table.Group(#"Filtered Rows1", {"Name"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each if [Count]>1 then "Yes" else "NO"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Count"}),
    #"Transposed Table" = Table.Transpose(#"Removed Columns")
in
    #"Transposed Table"
 
Upvote 0
If you use Power Query, the following will generate a report that shows who travelled during that time frame and if they visited more than one city.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Arrival Date", type date}, {"Departure Date", type date}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Arrival Date] >= #date(2021, 2, 1) and [Arrival Date] <= #date(2021, 2, 28)),
    #"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each [Departure Date] >= #date(2021, 2, 1) and [Departure Date] <= #date(2021, 2, 28)),
    #"Grouped Rows" = Table.Group(#"Filtered Rows1", {"Name"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each if [Count]>1 then "Yes" else "NO"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Count"}),
    #"Transposed Table" = Table.Transpose(#"Removed Columns")
in
    #"Transposed Table"
Thanks for your response. Unfortunately I'm not well versed with Power Query.
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

If you have MS365, you could try this

21 12 15.xlsm
ABCDEFGHIJKLMN
1NamePlaceArrival DateDeparture DatePeriod FromPeriod ToDavisHenryJohnKateMitchelNaomiPeter
2PeterLondon1/02/20213/02/20211/02/202128/02/2021YesNoNoYesYesNoNo
3DavisKairo4/02/20217/02/2021
4NaomiNew York2/01/20216/01/2021
5HenryLondon3/01/20215/01/2021
6KateSingapore12/01/202117/01/2021
7DavisDubai10/02/202112/02/2021
8PeterParis15/01/202119/01/2021
9KateNew Delhi5/02/20218/02/2021
10JohnDubai4/05/20218/05/2021
11MitchelLondon18/02/202121/02/2021
12HenryParis7/01/202112/01/2021
13NaomiNew Delhi8/01/202115/01/2021
14PeterLondon24/02/202128/02/2021
15MitchelDubai23/02/202124/02/2021
16MitchelLondon26/02/202128/02/2021
17NaomiSingapore12/02/202116/02/2021
18KateNew Delhi21/02/202125/02/2021
19HenryParis15/01/202120/01/2021
20DavisLondon25/02/202128/02/2021
21KateDubai12/02/202118/02/2021
>1
Cell Formulas
RangeFormula
H2:N2H2=IF(ROWS(UNIQUE(FILTER($B2:$B21,($A2:$A21=H1)*($C2:$C21<=$G2)*($D2:$D21>=$F2),"")))>1,"Yes","No")
 
Upvote 0
This should assist you in understanding PQ
Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

- Follow this link to learn how to install Power Query in Excel 2010 / 2013.

- Follow this link for an introduction to Power Query functionality.

- Follow this link for a video which demonstrates how to use Power Query code provided.
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

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