Number of Weeks Between First and Last of a List of Dates

AnyaK

New Member
Joined
Jun 5, 2017
Messages
36
Office Version
  1. 365
Platform
  1. Windows
Hello,

Please could I ask for some help?

I have a list of clients and the dates of their appointments. For each client, I would like to work out the number of weeks between their first appointment (earliest date) and last appointment (most recent date).

I would be really grateful for your help.

Many thanks,

AnyaK

Example for MrExcel 21102024.xlsx
AB
1Client IDDate of Appointment
2Client 101/01/2024
3Client 102/02/2024
4Client 103/02/2024
5Client 112/03/2024
6Client 122/03/2024
7Client 101/05/2024
8Client 102/05/2024
9Client 103/05/2024
10Client 107/05/2024
11Client 123/05/2024
12Client 101/06/2024
13Client 202/01/2024
14Client 217/01/2024
15Client 227/01/2024
16Client 203/02/2024
17Client 207/02/2024
18Client 303/03/2024
19Client 321/03/2024
Sheet1
 
Last edited by a moderator:

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hello, if you already have access to the new GROUPBY function, then maybe something like:

Excel Formula:
=LET(
clients,A2:A19,
dates,B2:B19,
first,DROP(GROUPBY(clients,dates,MIN,,0),,1),
last,DROP(GROUPBY(clients,dates,MAX,,0),,1),
HSTACK(UNIQUE(SORT(clients)),DATEDIF(first,last,"D")/7))
 
Upvote 0
Hello, if you already have access to the new GROUPBY function, then maybe something like:

Excel Formula:
=LET(
clients,A2:A19,
dates,B2:B19,
first,DROP(GROUPBY(clients,dates,MIN,,0),,1),
last,DROP(GROUPBY(clients,dates,MAX,,0),,1),
HSTACK(UNIQUE(SORT(clients)),DATEDIF(first,last,"D")/7))


Hi hagia_sofia

I really appreciate you taking the time to reply.

Unfortunately, I don't' have access to the GROUPBY function.

My apologies
 
Upvote 0
Many thanks for the reply. Please test this then:

Excel Formula:
=LET(
clients,A2:A19,
dates,B2:B19,
u,UNIQUE(clients),
first,MINIFS(dates,clients,u),
last,MAXIFS(dates,clients,u),
HSTACK(u,DATEDIF(first,last,"D")/7))
 
Upvote 0
Solution
Many thanks for the reply. Please test this then:

Excel Formula:
=LET(
clients,A2:A19,
dates,B2:B19,
u,UNIQUE(clients),
first,MINIFS(dates,clients,u),
last,MAXIFS(dates,clients,u),
HSTACK(u,DATEDIF(first,last,"D")/7))

Thanks again for your help. Unfortunately, I'm getting a #SPILL! error.
 
Upvote 0
#SPILL! error means either that there are some values that are blocking the formula from spilling, or the formula is placed into an official Excel table - could you please insert the formula somewhere where there are blank cells within 2 columns to test it and provide the feedback if it calculates and it is how the output should look like?
 
Upvote 0
#SPILL! error means either that there are some values that are blocking the formula from spilling, or the formula is placed into an official Excel table - could you please insert the formula somewhere where there are blank cells within 2 columns to test it and provide the feedback if it calculates and it is how the output should look like?
Thanks so much, it now works perfectly!

My apologies for my error in initially placing the formula in a table.

Thanks again.
 
Upvote 0

Forum statistics

Threads
1,223,883
Messages
6,175,168
Members
452,615
Latest member
bogeys2birdies

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