For my Fiscal Calendar in Power BI I am currently trying to implement the 4-4-5 approach.
Our calendar works with 4-4-5 week quarters. Since this only has 364 days each year, there must be a 53 week year after a few years. As a result, December has 6 instead of 5 weeks. Unfortunately, there is still no approach based on DAX. In another post here, however, I found a JAVA code, which probably determines whether the year has 53 weeks or not: calculate number of weeks in a given year
private static long getNumberOfWeeksInYear(LocalDate date) {
LocalDate middleOfYear = date.withDayOfMonth(1).withMonth(6);
return middleOfYear.range(WeekFields.ISO.weekOfWeekBasedYear()).getMaximum();
}
public static void main(String[] args) {
for (int year = 2000; year < 2400; year++) {
long numberOfWeeks = getNumberOfWeeksInYear(LocalDate.of(year, 1, 1));
if (numberOfWeeks != 52) {
System.out.println(year + " has " + numberOfWeeks + " weeks");
}
}
}
Do any of you know how to translate the code into Dax?
Our Fiscal Calendar starts not based on the gregorian calendar. This year starts at 30.12.19 and ends 03.01.21. This year has 53 weeks.