Rules / Formatting

Objects should not start or end with a space

error OBJECTS_SHOULD_NOT_START_OR_END_WITH_A_SPACE · ported · model layer · scope: Model, Table, Measure, Hierarchy, Perspective, Partition, Column, CalculatedColumn

What it checks

Names that start or end with a space, for the model, tables, measures, hierarchies, perspectives, partitions, data columns, and calculated columns.

Each finding names the object the way the rest of the tool does: a column as 'Sales'[Order ID ], a measure as [Total Sales ], a table as 'Sales ', a hierarchy or a partition by its name with its table in the detail, and a perspective by its name alone. The space is inside the name, so the line reads as though nothing were wrong with it.

Example

Fires the rule
table Sales
	column 'Order ID '
		dataType: int64
		summarizeBy: none
		sourceColumn: OrderID

	column Amount
		dataType: decimal
		summarizeBy: none
		sourceColumn: Amount
After the fix
table Sales
	column 'Order ID'
		dataType: int64
		summarizeBy: none
		sourceColumn: OrderID

	column Amount
		dataType: decimal
		summarizeBy: none
		sourceColumn: Amount

Why it matters

A leading or trailing space is invisible on screen but is part of the name, so "Sales " and "Sales" are two different objects to the engine. That is enough to break a DAX reference, a report visual binding, or a deployment that expects the trimmed name, and the error you get back will name an object that looks perfectly correct. Stray spaces almost always arrive by accident, pasted in or inherited from a source column name, so trimming them is safe and rarely breaks anything downstream. TRIM_OBJECT_NAMES makes the same check across more object types at a lower severity, so every finding here appears there as well.

How to fix it

In Power BI Desktop, double-click the field in the Data pane and retype the name without the space, or select the object and clear the space from Name in the Properties pane. In the TMDL file the name is on the declaration line, so column 'Order ID ' becomes column 'Order ID'. A data column carries its own sourceColumn, so trimming the model name does not change what the refresh loads. Renaming in Desktop updates the visuals bound to the field; a hand edit in the file does not, so open the report and check its visuals after one. Where the space arrives with a source column name, trim it in Power Query too, so the next column you add from that query comes in clean.

When to ignore it

No name should start or end with a space, and this rule reports at error severity because a name that reads as correct and is not costs more to diagnose than to fix. A leading space is sometimes used to push a measure to the top of the field list; a display folder puts the measure where it belongs without hiding a character in its name.

To ignore this rule on one object, add annotation pbiplint.ignore = OBJECTS_SHOULD_NOT_START_OR_END_WITH_A_SPACE under the object in its TMDL file. Power BI Desktop keeps the annotation. To turn the rule off for a whole project, set "OBJECTS_SHOULD_NOT_START_OR_END_WITH_A_SPACE": "off" under rules in pbiplint.config.json.

Quirks

Ported from Microsoft's Best Practice Analyzer ruleset (opens in a new tab).

Check a model for this Improve this page (opens in a new tab)