Hi I have used the AI tool to help me create the following function, however the intellisense does not recognise the STARTOF WEEK or ENDOFWEEK function
Please see code below;
Last_Week_Sales_Comparison =
VAR CurrentWeekNumber = WEEKNUM(TODAY(), 2)
VAR LastWeekStartDate = TODAY() - WEEKDAY(TODAY(), 2) - 6
VAR LastWeekEndDate = TODAY() - WEEKDAY(TODAY(), 2)
VAR LastYearWeekNumber = CurrentWeekNumber - 1
VAR LastYearDate = EDATE(LastWeekStartDate, -12) // 12 months back for last year
VAR LastYearStartDate = STARTOFWEEK(LastYearDate, 2)
VAR LastYearEndDate = ENDOFWEEK(LastYearStartDate, 2)
RETURN
SUMX(
FILTER(
Sales,
Sales[Posting Date]>= LastWeekStartDate &&
Sales[Posting Date] <= LastWeekEndDate
),
Sales[Sales Amount]
) -
SUMX(
FILTER(
Sales,
Sales[Posting Date] >= LastYearStartDate &&
Sales[Posting Date] <= LastYearEndDate
),
Sales[Sales Amount]
)
The error I face,
Too many arguments were passed to the STARTOFWEEK function. The maximum argument count for the function is 1.