Rules / Maintenance

Perspectives with no objects

info PERSPECTIVES_WITH_NO_OBJECTS · ported · model layer · scope: Perspective

What it checks

Perspectives that contain no tables. The rule reads only a perspective's table entries, which is enough: each column, measure, and hierarchy a perspective includes sits under the entry for its table, so with no table entry it includes nothing.

Each finding names the perspective on its own, as Sales View, with no table and no quotes around it, because a perspective belongs to the model rather than to a table.

Example

Fires the rule
table Sales
	column Amount
		dataType: decimal
		sourceColumn: Amount

	measure 'Total Sales' = SUM('Sales'[Amount])
		formatString: #,0

perspective 'Sales View'
After the fix
table Sales
	column Amount
		dataType: decimal
		sourceColumn: Amount

	measure 'Total Sales' = SUM('Sales'[Amount])
		formatString: #,0

perspective 'Sales View'

	perspectiveTable Sales

		perspectiveMeasure 'Total Sales'

Why it matters

An empty perspective still shows up in clients that offer perspectives, such as Excel, as a named view of the model that contains nothing. It is either an abandoned start or the remains of objects that were removed, and it leaves the next person asking what it was for.

How to fix it

Power BI Desktop has no graphical editor for perspectives, and its TMDL view is the route Microsoft gives (Common use cases for TMDL view (opens in a new tab)). A perspective is a perspective block of its own, and the objects it shows are perspectiveTable entries under it, with the columns, measures, and hierarchies it shows listed beneath each one. In TMDL view, write a createOrReplace script of the whole perspective with the tables it should show, and select Apply. To remove the perspective instead, close Desktop, delete its file from the perspectives folder, and drop the matching ref perspective line from model.tmdl. Tabular Editor edits perspectives in a UI if you would rather tick boxes than edit the file.

When to ignore it

There is no case for it. A perspective you have created and not yet filled is the one you want reported, because nothing else will tell you it is still empty, and an empty perspective in a published model offers a report author a view of the model with no fields in it.

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