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 September 15. Request your voucher.

Reply
ArchStanton
Impactful Individual
Impactful Individual

Second Date Table errors

Hi,
My data model has and needs 2 date tables: Date 1 and Date 2. 
Date 1 works fine but Date 2 doesn't.

 

The Code for Date 1 and is based on 'Caseload' table that does not contain a Resolution Date

Date1 = 

VAR FYStartMonth = 4 -- use 4 (Apr), 7 (Jul) or 10 (Oct)
VAR FYStartYear = YEAR(MIN('Caseload'[Created On - System]))
VAR StartDate = DATE(2019,4,1)
VAR Endate = DATE(2026,03,31)
VAR FYCalStart = DATE(FYStartYear, FYStartMonth, 1)


RETURN ADDCOLUMNS(
    CALENDAR(StartDate, Endate),
    "CalYear", YEAR([Date]),
    "CalQtrNumber", Quarter([Date]),
    "CalMthNumber", MONTH([Date]),
    "DayofMthNumber", DAY([Date]),
    "DayofWkNumber", WEEKDAY([Date],2),
    "MonthName", FORMAT([Date], "mmm"),
    "DayofWkName", FORMAT([Date], "ddd"),
    "CalQtrName", "Qtr" & QUARTER([Date]),
    "YearMthName", FORMAT([Date], "yyyy-mmm"),
    "YearMthNum", (YEAR([Date]) * 100) + MONTH([Date]),
    "FY", "FY" & YEAR([Date]) - (Month([Date]) < FYStartMonth) & "/" & 
            YEAR([Date]) + (Month([Date]) >= FYStartMonth),
    "FYMonthNo", MOD(MONTH([Date]) - FYStartMonth, 12) +1,
    "FY Qtr", "Q" & ROUNDUP(DIVIDE(MOD(MONTH([Date]) - FYStartMonth, 12) +1, 3), 0),
    "CurrentMthNo", MONTH(TODAY()))

 

Date2= This is based on Closures table because it contains a Resolution Date. The range of dates here are very different to the Caseload Table.

Date2 = 

VAR FYStartMonth = 4 -- use 4 (Apr), 7 (Jul) or 10 (Oct)
VAR FYStartYear = YEAR(MIN('Closures'[Created On - System])
VAR StartDate = DATE(2021,1,1)
VAR Endate = MAX('Closures'[Resolution Date])
VAR FYCalStart = DATE(FYStartYear, FYStartMonth, 1)


RETURN ADDCOLUMNS(
    CALENDAR(StartDate, Endate),
    "CalYear", YEAR([Date]),
    "CalQtrNumber", Quarter([Date]),
    "CalMthNumber", MONTH([Date]),
    "DayofMthNumber", DAY([Date]),
    "DayofWkNumber", WEEKDAY([Date],2),
    "Mth ", FORMAT([Date], "mmm"),
    "DayofWkName", FORMAT([Date], "ddd"),
    "CalQtrName", "Qtr" & QUARTER([Date]),
    "YearMthName", FORMAT([Date], "yyyy-mmm"),
    "YearMthNum", (YEAR([Date]) * 100) + MONTH([Date]),
    "FY", "FY" & YEAR([Date]) - (Month([Date]) < FYStartMonth) & "/" & 
            YEAR([Date]) + (Month([Date]) >= FYStartMonth),
    "FYMonthNo", MOD(MONTH([Date]) - FYStartMonth, 12) +1,
    "FY Qtr", "Q" & ROUNDUP(DIVIDE(MOD(MONTH([Date]) - FYStartMonth, 12) +1, 3), 0))

 

Date2 is going to be used for Time Intelligence analysis on Closures (Cases that have a Resolution Date).

 

Can anyone explain why Date2 is saying the Syntax for 'VAR' is incorrect please?

ArchStanton_0-1745581150555.png

 

FYI: The earliest Created On Date in Closures is 06/05/2021 but in the Caseload Table its 30/03/2019. 

That is why the dates in both sets of Variables are different between Date1 and Date2.

 

Ps.This set up works in a different PowerBI report of mine but the difference there is that I only use one table (Caseload) because it contains a Resolution Date field.

Thanks

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@ArchStanton,

 

Line 4 (VAR FYStartYear) needs an additional closing parenthesis at the end.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
DataInsights
Super User
Super User

@ArchStanton,

 

Line 4 (VAR FYStartYear) needs an additional closing parenthesis at the end.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Can't believe I didn't spot that! 

 

Thank you!!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors