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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
ArchStanton
Power Participant
Power Participant

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.