The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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?
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
Solved! Go to Solution.
Line 4 (VAR FYStartYear) needs an additional closing parenthesis at the end.
Proud to be a Super User!
Line 4 (VAR FYStartYear) needs an additional closing parenthesis at the end.
Proud to be a Super User!
Can't believe I didn't spot that!
Thank you!!