Forum

Notifications
Clear all

Count Number for each month and year

11 Posts
5 Users
0 Reactions
118 Views
(@paul-sanft)
Posts: 35
Trusted Member
Topic starter
 

Hi All,

The attached excel has four columns (all related to students on a course):

Student Number

Year the Course Finished

Date the Course Started, and

Date the Course Finished.

 

What I need to know is what Month and Year they were on course for each Calendar month.

 

I hope someone can help, I know I can counts months but it's not what I need to report on.

 

Regards

 
Posted : 17/07/2023 7:28 pm
Philip Treacy
(@philipt)
Posts: 1630
Member Admin
 

Hi Paul,

No file atatched.

regards

Phil

 
Posted : 17/07/2023 7:31 pm
(@paul-sanft)
Posts: 35
Trusted Member
Topic starter
 

This time 🙂

 
Posted : 18/07/2023 3:02 am
Alan Sidman
(@alansidman)
Posts: 223
Member Moderator
 

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Students", Int64.Type}, {"Year Finshed", type text}, {"Start Date", Int64.Type}, {"End Date", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Dates", each {[Start Date]..[End Date]}),
#"Expanded Dates" = Table.ExpandListColumn(#"Added Custom", "Dates"),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Dates",{{"Start Date", type date}, {"End Date", type date}, {"Dates", type date}}),
#"Inserted Month Name" = Table.AddColumn(#"Changed Type1", "Month Name", each Date.MonthName([Dates]), type text),
#"Inserted Month" = Table.AddColumn(#"Inserted Month Name", "Month", each Date.Month([Dates]), Int64.Type),
#"Sorted Rows" = Table.Sort(#"Inserted Month",{{"Month", Order.Ascending}}),
#"Removed Columns1" = Table.RemoveColumns(#"Sorted Rows",{"Month"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns1", List.Distinct(#"Removed Columns1"[#"Month Name"]), "Month Name", "Dates", List.Count)
in
#"Pivoted Column"

 
Posted : 18/07/2023 12:03 pm
Riny van Eekelen
(@riny)
Posts: 1195
Member Moderator
 

Not sure if Alan's Power Query solution gives you the results asked for. Please find a different (formula based) solution in the attached file.

 
Posted : 19/07/2023 1:45 am
(@paul-sanft)
Posts: 35
Trusted Member
Topic starter
 

Thanks Gents,

Riny; the shortened formula would be easier use but I think my limitation is how the data is down loaded I have attached a sample).  As you will see; I have attempted to use a SUMIFs but it is not, it appears, to be returning the correct information.

 

I am faced with competing issues; as a business we are still (until late next year) stuck with MS 2013 and secondly they want the info draw down from SharePoint (again 2013); so there are competing struggles with the ability to draw down and calc or create the calc fields in SharePoint. 

 

Anyway any guidance will be greatly appreciated.

 

Regards Paul

 

  

 
Posted : 25/07/2023 6:57 pm
(@debaser)
Posts: 837
Member Moderator
 

Your initial sample suggests you don't care about which year it is, just the month name - is that correct?

I think it's probably simplest just to generate a list of entries for each month from start date to end date, then split into rows before aggregating by month - either in PQ or with a pivot table.

 
Posted : 25/07/2023 7:21 pm
(@paul-sanft)
Posts: 35
Trusted Member
Topic starter
 

Thanks Velouria,

 

I like the concept; but possiblt too much work as the process will be requireing ongoing updating; and I am trying to sort data from 2016 to today (attempting to gather and having ongoing logitudinal volume for optimising training periods and reducing strerss volumes).

 

I have attached another sample using Riny's formula (created the calc colums in Sharepoint to replicate what Riny supplied); however the formula doesn't appera to wor, not sure if it's because I have done something wrong in the array or if it's just because I, using an older version of excel.

 

Anyway any guidance greatly appreciated

 

Paul 

 
Posted : 26/07/2023 4:36 pm
Riny van Eekelen
(@riny)
Posts: 1195
Member Moderator
 

See attached. It didn't work because the yyyy-mmm entries in columns D and E are texts, whereas the dates in row 2 are real (numerical dates).

Went back to my original file and changed yours to work accordingly, using the real start and end dates in stead of the yyyy-mmm columns. Then I also changed row 2 to contains month-END dates.

Entered the formula with C-S-E since that how your file had it and copied the lot down. Seems to work just fine.

 
Posted : 27/07/2023 2:04 am
(@debaser)
Posts: 837
Member Moderator
 

I'm not sure how it would be too much work - the query does it all? See attached demo - I used a pivot table for the output but you could also make it a table if you wanted to.

 
Posted : 27/07/2023 4:29 am
(@paul-sanft)
Posts: 35
Trusted Member
Topic starter
 

Riny & Velouria,

I thanks you both very much for your assistance, it's likely both your options will be in use when I develop my final plan.  I'm really annoyed that I missed the text vs number format, doh.

 

Anyway thanks again Gents

Live Long and Excel

 
Posted : 28/07/2023 2:34 am
Share: