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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MCacc
Helper IV
Helper IV

Build calendar using year

Hello, I'm trying to build a calendar where the min date starts 20 years ago from this year, and max date is 5 years ago from this year.

 

So because I'm 2024: 

 

The first date is: 

01/01/2004

 

The last date is

31/12/2019

 

Thank you

1 ACCEPTED SOLUTION

@MCacc 

 

CalendarTable =
VAR MinDate = DATE(YEAR(TODAY()) - 20, 1, 1)
VAR MaxDate = DATE(YEAR(TODAY()) - 5, 12, 31)
RETURN
ADDCOLUMNS (
CALENDAR (MinDate, MaxDate),
"Year", YEAR([Date]),
"Month", MONTH([Date]),
"Day", DAY([Date]),
"MonthName", FORMAT([Date], "MMMM"),
"Quarter", "Q" & FORMAT([Date], "Q")
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

4 REPLIES 4
Khushidesai0109
Super User
Super User

Hiii @MCacc 

CalendarTable =
VAR StartDate = DATE(YEAR(TODAY()) - 20, 1, 1)
VAR EndDate = DATE(YEAR(TODAY()) - 5, 12, 31)
RETURN
ADDCOLUMNS (
    CALENDAR(StartDate, EndDate),
    "Year", YEAR([Date]),
    "Month", MONTH([Date]),
    "Day", DAY([Date]),
    "MonthName", FORMAT([Date], "MMMM"),
    "Quarter", "Q" & FORMAT([Date], "Q")
)
this dax would help you to make a calendar dynamically as the year goes on...

Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!!
bhanu_gautam
Super User
Super User

@MCacc , Go to modelling tab and select new table and use

 

DAX
DateTable =
VAR StartDate = DATE(2004, 1, 1)
VAR EndDate = DATE(2019, 12, 31)
RETURN
ADDCOLUMNS (
CALENDAR (StartDate, EndDate),
"Year", YEAR([Date]),
"Month", MONTH([Date]),
"Day", DAY([Date]),
"MonthName", FORMAT([Date], "MMMM"),
"Quarter", "Q" & FORMAT([Date], "Q")
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thank you, 

 

but is there any way I can achieve this dynamically starting from Today date?

 

Thank you

@MCacc 

 

CalendarTable =
VAR MinDate = DATE(YEAR(TODAY()) - 20, 1, 1)
VAR MaxDate = DATE(YEAR(TODAY()) - 5, 12, 31)
RETURN
ADDCOLUMNS (
CALENDAR (MinDate, MaxDate),
"Year", YEAR([Date]),
"Month", MONTH([Date]),
"Day", DAY([Date]),
"MonthName", FORMAT([Date], "MMMM"),
"Quarter", "Q" & FORMAT([Date], "Q")
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.