Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ifillingham
Frequent Visitor

Help creating an academic year calendar in Power Query

Hi there,

 

I hope someone can help me out with making an academic year calendar using Power Query rather than PowerBI and Dax. The reason for using Power Query rather than DAX is to limit any impact (of creating the academic calendar in DAX) on the end user when they interact with the dashboard.

 

I have a Master Term Dates file with the format as in the image below:

ifillingham_0-1625332340016.png

 

And a calendar like below in Power Query

ifillingham_1-1625332538240.png

 

My calendar needs to includes columns showing the relevant half-term, term and academic year information indicated by the start and end dates.

 

My ideal output would be:

ifillingham_2-1625333030925.png

 

For dates between 5/11/2018 and 21/12/2018, The columns would look show:

ifillingham_3-1625333226334.png

The Term and Academic Year are the same but the Half Term is different!

 

I know I need some kind of merge table function but this is beyond me at the minute.

 

I hope all of this makes sense!!

Thanks so much,

Ian

 

1 ACCEPTED SOLUTION
Migasuke
Super User
Super User

Hi,

The solution is quite simple.
1. Load your excel table in to the power query
2. Create a custom column with following formula: (this will create a dates in your table based on your start and end date)

Migasuke_0-1625334668929.png

3. Go to your new column and expand it to the rows:

Migasuke_1-1625334794384.png

4. Change Data Type of new column from Numbers to Dates
5. You have your wished calendar:

Migasuke_2-1625334935895.png


Let me know, if you solved it.





If my answer was helpful please give me a Kudos or even accept as a Solution.

Let's connect on LinkedIn!

View solution in original post

4 REPLIES 4
ifillingham
Frequent Visitor

Thanks so much,

 

When i thought about things a bit more, the calaendar will be recreated every time the model is refreshed.

Just want to say a massive thank you for answering my question. You genuienly have saved me hours of work!!

Best wishes,

Ian

ifillingham
Frequent Visitor

This is awesome!! Thanks so much @Migasuke 

 

I'm asking for a lot here.....

 

I'm just thinking of how I would add future academic years into my model.

  • If I start from a table in Power Query with one date column (with dates from a given start date until today),.
  • Each time I open up PowerBi, this date table will be updated such that the last date in the list is the current date.
  • Each date is compared to those provided in a Master Term Dates table which gives the start and end dates of half Terms, Terms, holidays etc in a number of academic years.
  • Could Power Query add columns which indicate the half Term, Term etc??

In this way, I would be able to manually edit one file with all the start/end dates of the various terms.

I hope all of this makes sense.

It's not a problem at all if this won't work.

Thanks so much again,

Ian

Hi,

you can definitelly automatize some of the points you mentioned above, problem is, that set up everything would require lot of rules in PQ.

In this case I would stick to the logic, which you have right now - basically you only need to maintain one excel sheet, few times per year instead of overcomplicating code.




If my answer was helpful please give me a Kudos or even accept as a Solution.

Let's connect on LinkedIn!

Migasuke
Super User
Super User

Hi,

The solution is quite simple.
1. Load your excel table in to the power query
2. Create a custom column with following formula: (this will create a dates in your table based on your start and end date)

Migasuke_0-1625334668929.png

3. Go to your new column and expand it to the rows:

Migasuke_1-1625334794384.png

4. Change Data Type of new column from Numbers to Dates
5. You have your wished calendar:

Migasuke_2-1625334935895.png


Let me know, if you solved it.





If my answer was helpful please give me a Kudos or even accept as a Solution.

Let's connect on LinkedIn!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors