Rules / Maintenance

Calculation groups with no calculation items

warning CALCULATION_GROUPS_WITH_NO_CALCULATION_ITEMS · ported · model layer · scope: CalculationGroupTable

What it checks

Calculation groups that contain no calculation items.

Each finding names the group's table, as 'Time Intelligence', because a calculation group is a table in the model files and pbiplint reports it as one.

Example

Fires the rule
table 'Time Intelligence'

	calculationGroup

	column 'Time Calculation'
		dataType: string
		summarizeBy: none
		sourceColumn: Name

	partition 'Time Intelligence' = calculationGroup
		mode: import

table Date
	column Date
		dataType: dateTime
		sourceColumn: Date
After the fix
table 'Time Intelligence'

	calculationGroup

		calculationItem YTD = CALCULATE(SELECTEDMEASURE(), DATESYTD('Date'[Date]))

	column 'Time Calculation'
		dataType: string
		summarizeBy: none
		sourceColumn: Name

	partition 'Time Intelligence' = calculationGroup
		mode: import

table Date
	column Date
		dataType: dateTime
		sourceColumn: Date

Why it matters

A calculation group with no items still appears in the field list as a table with one column, and dropping that column on a visual does nothing. It is usually a group that was started and abandoned, and it puzzles whoever finds it later.

How to fix it

In Power BI Desktop, open Model view, find the group under Calculation groups in the Model explorer pane, choose New calculation item, and write its DAX in the formula bar. In the TMDL file the group is a calculationGroup block under the table, and each item is a calculationItem inside it with its DAX after the =. If the group is not wanted, delete the table: in Desktop, right-click it in the Data pane and choose Delete from model; in the project, remove its file from the tables folder and its ref table line from model.tmdl.

When to ignore it

The one moment the finding is noise is while you are building the group, between creating it and writing the first item, when it tells you something you already know. There is no reason to ship one: an empty group is a field in the list that does nothing when a report author uses it.

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