microsoft / Analysis-Services

Git repo for Analysis Services samples and community projects
MIT License
607 stars 416 forks source link

BPA - Trim Object rule error #200

Open benito2313 opened 1 year ago

benito2313 commented 1 year ago

Hi,

On the new rule "Trim object names" i get an error when i try to ignore it. This is when its on a calculation item.

I get the following error: One or more of the selected objects does not support annotations. For this reason, the rule cannot be ignored on these objects.

Kind regards,

Ben

m-kovalsky commented 1 year ago

When ignoring a rule for a given object, Tabular Editor adds an annotation to that object. Then, Tabular Editor reads these annotations when showing/hiding such objects within the Best Practice Analyzer. Calculation Items inherently do not have an annotation property within TOM (tabular object model) so it generates this error message. This would be the case with any BPA rule which references Calculation Items - not just this rule.

@otykier curious what you think of this.

otykier commented 1 year ago

Well, if you want the rule to ignore calculation items in general, simply remove calc items from the scope of the rule (the "Applies to" dropdown within the Edit Best Practice Rule dialog).

If you want more granular control, you'll have to edit the rule expression. For example, if you want to ignore a calc item with the name "YTD " (note the trailing space), you should modify the expression to:

(Name.StartsWith(" ") or Name.EndsWith(" "))
and Name <> "YTD "

If you create a rule within the model itself with the same ID as the rule from this repo (TRIM_OBJECT_NAMES), then that rule will take precedence over the rule defined in this repo, letting you add additional exceptions by modifying its expression as shown above.