Rules / Error Prevention

Data columns must have a source column

error DATA_COLUMNS_MUST_HAVE_A_SOURCE_COLUMN · ported · model layer · scope: Column

What it checks

Data columns with no source column. Calculated columns are not checked.

Each finding names the column, as 'Sales'[Amount]. The partition whose query should have produced the value is not in the line, so read the table's partitions to see what the column was meant to come from.

Example

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

	column Amount
		dataType: decimal

	partition Sales = m
		mode: import
		source =
				let
					Source = Sql.Database("localhost", "Sales"),
					Sales = Source{[Schema="dbo",Item="Sales"]}[Data]
				in
					Sales
After the fix
table Sales
	column 'Order ID'
		dataType: int64
		sourceColumn: OrderID

	column Amount
		dataType: decimal
		sourceColumn: Amount

	partition Sales = m
		mode: import
		source =
				let
					Source = Sql.Database("localhost", "Sales"),
					Sales = Source{[Schema="dbo",Item="Sales"]}[Data]
				in
					Sales

Why it matters

A data column is filled from a column in the partition query, and the source column name is how the engine finds it. Without it, processing fails for the whole table, with an error that names the column but not the cause.

How to fix it

Power BI Desktop writes sourceColumn whenever it adds a column to a table, so a finding here means the column was written or edited by hand, or arrived in a migration. In the TMDL file, add a sourceColumn: line under the column, naming the field the partition's query produces and spelling it the way the query spells it. Where the query no longer produces it, the fix runs the other way: add the column back in Power Query, under Transform data, so the next refresh delivers it, or take the column out of the model, in Desktop by right-clicking it in the Data pane and choosing Delete from model, or by removing its column block from the table's TMDL file.

When to ignore it

There is none. A data column with no source column stops the whole table from loading, so the finding is a refresh failure reported before the refresh. The one thing worth checking is whether the column was meant to be a calculated column: if it was, give it a DAX expression instead, and the column leaves this rule for EXPRESSION_RELIANT_OBJECTS_MUST_HAVE_AN_EXPRESSION, which asks the same question of the expression.

To ignore this rule on one object, add annotation pbiplint.ignore = DATA_COLUMNS_MUST_HAVE_A_SOURCE_COLUMN under the object in its TMDL file. Power BI Desktop keeps the annotation. To turn the rule off for a whole project, set "DATA_COLUMNS_MUST_HAVE_A_SOURCE_COLUMN": "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)