Rules / Maintenance

Remove data sources not referenced by any partitions

info REMOVE_DATA_SOURCES_NOT_REFERENCED_BY_ANY_PARTITIONS · ported · model layer · scope: DataSource

What it checks

Data sources that no partition names and that appear nowhere in any partition's query or M text.

Each finding names the data source on its own, as Legacy SQL, because a data source belongs to the model rather than to a table.

Example

Fires the rule
dataSource 'Legacy SQL' = provider
	connectionString: Data Source=contoso;Initial Catalog=Warehouse
	impersonationMode: impersonateServiceAccount

table Sales
	column Amount
		dataType: decimal
		sourceColumn: Amount

	partition Sales = m
		mode: import
		source = let Source = Sql.Database("contoso", "Sales") in Source
After the fix
table Sales
	column Amount
		dataType: decimal
		sourceColumn: Amount

	partition Sales = m
		mode: import
		source = let Source = Sql.Database("contoso", "Sales") in Source

Why it matters

An unused data source is a connection string, and usually a credential, that the model still asks to have configured on every deployment, so the service keeps prompting for credentials to a source nothing reads. It is a leftover from a migration or a source that was replaced.

How to fix it

Delete the data source. In the project it is a dataSource block, usually in a file of its own under the dataSources folder: remove the file and the matching ref line in model.tmdl, or delete the block where it sits. Power BI Desktop does not show data sources, and Transform data, Data source settings lists the sources the queries name rather than these declarations, so the file is the place to do it. If the source is still wanted, point a partition at it instead, with dataSource: under the partition's source block.

When to ignore it

A model whose partitions are created after it is deployed, by a pipeline or a script that binds them to a source the files do not yet name, keeps the declaration on purpose, and the finding on it is noise. So is a source you have just added and are about to wire up. Outside those, a data source nothing reads is a leftover, and the credential prompt it produces on every deployment is the cost of keeping it.

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