Formula Errors

Fix the DAY Syntax Error in Excel Power Pivot DAX Measures

Elise WilliamsElise Williams Nov 13, 2026 870 views

Question details

The user needs to resolve a DAY syntax error when editing or copying a DAX measure that uses AVERAGEX and DATESINPERIOD.

Fix the DAY Syntax Error in Excel Power Pivot DAX Measures
Product
Microsoft Excel Power Pivot
Device & OS
not provided
Scenario
Create or edit a rolling-average sales measure in the Excel Data Model for use in a PivotTable.
Observed behavior
The measure may calculate in a PivotTable, but the formula editor reports a syntax error near DAY when the expression is edited or copied.
Before you start

Open the measure in the Power Pivot measure editor, not a worksheet cell, and confirm that 'Calendar'[Date] and [Total Sales] exist in the Data Model. Check whether your editor expects commas or semicolons as argument separators.

Solution 1Recommended

Check the DATESINPERIOD argument separators and DAY keyword

Use this first when the editor highlights DAY or reports an error after copying the measure.

The standard date-column syntax is DATESINPERIOD(date_column, start_date, number_of_intervals, interval). DAY is an interval keyword, not a quoted text value.

The source discussion reports that adding an extra comma before DAY worked in one environment. However, -90,,DAY is not standard four-argument DATESINPERIOD syntax and should not be treated as a general fix.

1
Open the existing measure

In Excel, select Power Pivot > Measures > Manage Measures, select the affected measure, and click Edit. Menu names can vary by Excel version.

2
Enter the standard four-argument expression

In the formula field, enter: =AVERAGEX(DATESINPERIOD('Calendar'[Date],MAX('Calendar'[Date]),-90,DAY),[Total Sales]). Keep DAY unquoted and use one separator between -90 and DAY.

3
Match the editor's separator convention

If your editor uses semicolons, enter: =AVERAGEX(DATESINPERIOD('Calendar'[Date];MAX('Calendar'[Date]);-90;DAY);[Total Sales]). Retype the separators manually to eliminate copy-and-paste punctuation issues.

4
Validate and test the measure

Click Check Formula if available, then save the measure. In the PivotTable, select a known date range and compare the result with the expected average for that period.

Check the DATESINPERIOD argument separators and DAY keyword
A working PivotTable does not validate newly pasted text: The PivotTable may still be using the previously saved measure. Confirm that the edited expression validates and saves before treating its syntax as correct.
Free Microsoft Office alternative

Use WPS Spreadsheets for Everyday Sales Analysis

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for Microsoft Excel formats, making it easy to move ordinary worksheets and sales reports. It does not fix Excel Power Pivot DAX errors or replace the Power Pivot measure editor; keep DAX-based analysis in a compatible Microsoft tool.

Open and edit Microsoft Excel .xlsx and .xls worksheet files.Analyze exported sales data with spreadsheet formulas, filters, and charts.Use a familiar interface for an easy transition from everyday Excel work.Work with a lightweight office suite for routine reporting without relying on DAX measures.
QA img-9

Frequently Asked Questions

Should I add a second comma before DAY?

Not as a general fix. Standard date-column DATESINPERIOD syntax uses four arguments, with one separator between the interval count and DAY. In Power Pivot > Measures > Manage Measures, first test the standard expression and the separator convention required by your editor.

Does DAY need quotation marks in a DAX measure?

No. In DATESINPERIOD, DAY is an interval keyword. Enter DAY without quotation marks in the measure formula; do not enter "DAY" as a text value.

Why does my PivotTable work while the formula editor reports an error?

The PivotTable may be using the last successfully saved measure, while the edited or pasted expression contains different separators or punctuation. Open the measure editor, validate the current expression, save it, and then check the PivotTable again.

Will subtracting 180 in DATESBETWEEN produce a 180-day window?

Not with a complete daily calendar and inclusive endpoints. DATESBETWEEN('Calendar'[Date],MAX('Calendar'[Date])-180,MAX('Calendar'[Date])) covers 181 calendar dates. Subtract 179 for an inclusive 180-day window.

Can WPS Spreadsheets repair this Power Pivot measure?

No. WPS Spreadsheets is suitable for ordinary Excel-format worksheets and exported sales reports, but it is not a Power Pivot DAX measure editor. Correct the measure in Excel Power Pivot; if needed, export the results to a normal worksheet for use in WPS.