Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. 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.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 55 | |
| 40 | |
| 36 | |
| 20 | |
| 18 |
| User | Count |
|---|---|
| 73 | |
| 72 | |
| 38 | |
| 35 | |
| 26 |