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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Courtb86
Frequent Visitor

Leap Year - Previous Month

I have a calendar and its not showing dates from 02/29 and I feel really dumb asking this but can someone look at my code and let me know how to fix this?

 

Calendar =
VAR BaseCalendar =
CALENDAR("01/01/2023", "12/31/2040")
RETURN
GENERATE (
BaseCalendar,
VAR BaseDate = [Date]
VAR DayNum = WEEKDAY(BaseDate, 1)
VAR DayDate = DAY(BaseDate)
VAR WeekDate = WEEKDAY(BaseDate, 1)
VAR YearDate = YEAR(BaseDate)
VAR MonthNumber = MONTH ( BaseDate )
VAR MonthName = FORMAT ( BaseDate, "mmmm" )
VAR MonthYear = CONCATENATE(CONCATENATE(MonthName, ", "), YearDate)
VAR CurrentYear = IF( YearDate = YEAR(TODAY()), "TRUE", "FALSE")
VAR PrevMonth = IF(MonthNumber = MONTH(TODAY())-1, "TRUE", "FALSE")
VAR LatestMonth = IF(CurrentYear = "TRUE" && PrevMonth = "TRUE", "Previous Month", MonthName)
RETURN ROW (
"Day", DayDate,
"DayNum", DayNum,
"WeekDate", WeekDate,
"Year", YearDate,
"Month Number", MonthNumber,
"Month", MonthName,
"MonthYear", MonthYear,
"PreviousMonth", PrevMonth,
"CurrentYear", CurrentYear,
"Previous Month", LatestMonth
)
)
1 ACCEPTED SOLUTION
JamesFR06
Resolver IV
Resolver IV

Hello

 

I've tried your code on my pc and no error and last date is 31/12/2040

View solution in original post

3 REPLIES 3
JamesFR06
Resolver IV
Resolver IV

uld be inside datas or not. WHen you asked to genrate to this date to this one, for me he is not taking care of datas

JamesFR06
Resolver IV
Resolver IV

Hello

 

I've tried your code on my pc and no error and last date is 31/12/2040

Weird because the relationships I have are not showing 02/29/2024 that I know has data within them. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.