Power BI Calendar Script
This example is a block of code to create a calculated table in Power BI to generate a calendar based on a date field. This example defines the financial (fiscal) year as starting July 1.
There are a few points to note:
Update the date field (my_table[my_date]) in the Min and Max functions to be your date field
Join the source date to the date field in this new table
Mark the new table as a Date Table and ensure the Date field is selected when prompted
Calendar = AddColumns ( CALENDAR( Min ( my_table[my_date] ), Max ( my_table[my_date] ) ), "Financial Year", Year ( Edate ( [Date], -6 ) ) & "/" & Year ( EDate ( [Date], 6 ) ), "Year", YEAR ([Date]), "Month", Format ([Date], "MMM"), "Month Year", Format ( [Date], "MMM - YYYY"), "Period",IF(Month([Date])>6, Month([Date])-6, Month([Date])+6 ) )