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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

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
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.