Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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!!
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 44 | |
| 43 | |
| 38 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 68 | |
| 66 | |
| 31 | |
| 28 | |
| 24 |