Power BI Time Saver: M Query Calendar
M Query Calendar code to save time on Power BI development and to enable monthly week - day analysis.
Developing an awesome Power BI report usually requires a separate calendar table either to manipulate the date more effectively or to bridge multiple fact tables. Instead of creating a calendar using Power BI UI every time and adding columns one by one, use this M Query Calendar and set up all the needed columns all at once!
What is special about this code?
***Save time and energy for other more important tasks: you can save yourself from tedious and repetitive work of creating a calendar every time you need one, not to mention all the needed, and frequently used columns! It can save ~30 min in your Power BI Development every time! This query will allow you to change the start date of the calendar but will auto-update to get today's date as the maximum date.
***Calculated Columns:
(1) Year Month -- Start of Month is calculated for each date so you can get Monthly data easily!
(2) FullWeek field -- this field will calculate whether the first week of the month was a complete week or not (Sun ~ Sat or Mon ~ Sun depending on the file you use). If it was incomplete, the FullWeek for the month will start at 0. If it was complete, it will start at 1. The field ranges from 0 to 5.
(3) Week_day field -- this field allows you to compare each week and day's value for multiple months and also to find the trend within a month. See the screenshot of the line chart in the cover for an example. Week_day field combines the complete week and day name for each month to make this happen and sort them in the right way.
I got the code. How do I use it?
I included a pdf file of how to guide with screenshots for every step! Look "How_To_Guide_MQuery_Calendar.pdf"
Week starting on Sunday vs. Monday. Which one are you using?
Since every business requires different ways, I included two calendar M Query Codes: one starts the week on Sunday ("Calendar_Sunday_start.txt") and the other starts the week on Monday ("Calendar_Monday_start.txt"). You will get both of these with a how to guide when you purchase!
To learn more tips and tricks on Power BI, visit: sooreed.wixsite.com/datasnooze
Available Fields: Date, Week of Year, Day Name, FullWeek, Week_day, Year, Month Name, Year Month, Month, Year_week