13 KiB
Make sure to also check out the PowerBI.com blog post on this topic!
Check out the PowerBI.com blog post on v1.1.
Check out this blog post to learn how to quantify the savings of following specific Best Practice Rules.
Check out this blog post to learn how to export the Best Practice Analyzer results into Excel.
Lastly, check out this YouTube video for an in-depth walkthrough of the Best Practice Rules and Tabular Editor's Best Practice Analyzer.
Purpose
Running this collection of rules inside Tabular Editor's Best Practice Analyzer will inform you of potential issues to fix or improvements to be made with regard to performance optimization and model design.
Compatibility
These best practice rules are compatible with any incarnation of tabular models - be it a model in Power BI Desktop, Power BI Dataset, Power BI Premium, SQL Server Analysis Services, or Azure Analysis Services. The only requirement is using Tabular Editor (version 2 or 3).
Feedback
We would love to hear feedback on how this tool has helped your organization. Please email feedback to: pbibestpractice@microsoft.com.
If you find any issues or have any requests for new rules, please submit an issue within this repository. Just prefix the issue with "BPARules" to make it easier to track.
Rule Details
The rules are divided into categories (i.e. Performance, DAX Expressions, Error Prevention, Formatting, Maintenance etc.) for easier viewing. Additionally, each rule has a description and many of the rules also have a reference article/video. Reading the rule description and article will provide context as to why the rule is important and why one should follow it. The rule descriptions are accessible by navigating to 'Tools' -> 'Manage BPA Rules...' -> 'Rules for the local user' -> Click on a rule -> Click 'Edit rule...'.
Setup (automated)
Following these steps will automatically load the Best Practice Rules into your local Tabular Editor. Note that this will overwrite the existing BPARules.json file (if you are already have one) so be sure to back up your existing rules file.
- Open Tabular Editor.
- Connect to a model.
- Run the following code in the Advanced Scripting window.
System.Net.WebClient w = new System.Net.WebClient();
string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
string url = "https://raw.githubusercontent.com/microsoft/Analysis-Services/master/BestPracticeRules/BPARules.json";
string version = System.Windows.Forms.Application.ProductVersion.Substring(0,1);
string downloadLoc = path+@"\TabularEditor\BPARules.json";
if (version == "3")
{
downloadLoc = path+@"\TabularEditor3\BPARules.json";
}
w.DownloadFile(url, downloadLoc);
Note: If you want to load the rules in Italian, Japanese or Spanish, replace the url parameter in the code above with the appropriate code below.
// Italian
string url = "https://raw.githubusercontent.com/microsoft/Analysis-Services/master/BestPracticeRules/Italian/BPARules.json";
// Japanese
string url = "https://raw.githubusercontent.com/microsoft/Analysis-Services/master/BestPracticeRules/Japanese/BPARules.json";
// Spanish
string url = "https://raw.githubusercontent.com/microsoft/Analysis-Services/master/BestPracticeRules/Spanish/BPARules.json";
- Close and reopen Tabular Editor.
- Connect to a model.
- Select 'Tools' from the File menu and select 'Best Practice Analyzer'.
- Click the Refresh icon (in blue).
Setup (manual)
- Download the BPARules.json file from this GitHub repository.
- Within the Start Menu, type %localappdata% and click Enter.
- Navigate to the 'TabularEditor' folder (if using Tabular Editor 3, navigate to the TabularEditor3 folder).
- Copy the rules file (.json) and paste it into the folder from Step 3.*
- Open Tabular Editor and connect to your model.
- Select 'Tools' from the File menu and select 'Best Practice Analyzer'.
- Click the Refresh icon (in blue).
Notes
-
The following rules require running an additional script before running the Best Practice Analyzer
- Avoid bi-directional relationships against high-cardinality columns *
- Large tables should be partitioned *
- Reduce usage of long-length columns with high cardinality *^
- Split date and time ***
- Fix referential integrity violations *
*These rules use Vertipaq Analyzer data. There are 2 methods to load this data into Tabular Editor:
-
Load Vertipaq Analyzer data directly from a server (instructions) (script).
-
Load Vertipaq Analyzer data from .vpax file (instructions) (script).
^Run this script while live-connected to the model.
***Run this script while live-connected to the model.
Requirements
Tabular Editor version 2.16.1 or higher.
Languages
Note: If you would like to volunteer to translate the Best Practice Rules into another language, please contact us at pbibestpractice@microsoft.com.
Version History
- 2023-06-20 Version 1.2.6
- New Rules
- [Error Prevention] Set IsAvailableInMdx to true on necessary columns
- [Performance] Avoid using many-to-many relationships on tables used for dynamic row level security
- Updated Rules
- [Maintenance] Remove unnecessary columns
- Rule now accounts for columns/tables used in Object Level Security (OLS)
- [Maintenance] Remove unnecessary columns
- New Rules
- 2023-02-14 Version 1.2.5
- New Rules
- [Error Prevention] Avoid invalid characters in names
- [Error Prevention] Avoid invalid characters in descriptions
- [Naming Conventions] Trim object names (#193)
- Updated Rules
- [DAX Expressions] Avoid using '1-x/y)' syntax
- Updated recommendation to use accurate calculation (#192)
- [Maintenance] Remove data sources not referenced by any partitions
- Updated rule logic to account for M source expressions and M queries (#197)
- New Rules
- 2023-01-16 Version 1.2.4
- Fixed a bug in the Set IsAvailableInMdx Rule #190
- 2023-01-09
- The Best Practice Rules are now available in Spanish!
- 2022-11-22 Version 1.2.3
- The Best Practice Rules are now available in Japanese!
- New Rules
- [DAX Expressions] The EVALUATEANDLOG function should not be used in production models (#163)
- Updated Rules
- [Performance] Check if dynamic row level security (RLS) is necessary
- Updated the scope of the rule to Table Permissions (#178)
- [Performance] Minimize Power Query transformations
- Removed 'select' from the Native.Query function portion of the rule
- [Performance] Remove redundant columns in related tables
- Added description
- [Formatting] Provide format string for "Date" columns
- Updated description
- [DAX Expressions] No two measures should have the same definition
- Added description
- [Error Prevention] Data columns must have a source column
- Updated description
- [Performance] Check if dynamic row level security (RLS) is necessary
- 2022-06-06 Version 1.2.2
- New Rules
- [DAX Expressions] Avoid using the '1-(x/y)' syntax
- [Error Prevention] Avoid the USERELATIONSHIP function and RLS against the same table
- [Error Prevention] Relationship columns should be of the same data type
- Updated Rules
- [Formatting] Percentage formatting
- Fixed a bug within the fix expression
- [Formatting] Percentage formatting
- New Rules
- 2021-10-21
- The Best Practice Rules are now available in Italian!
- 2021-08-18 Version 1.2.1
- New Rules
- [Maintenance] Fix referential integrity violations (blog post)
- New Rules
- 2021-07-26 Version 1.2
- New Rules
- [Error Prevention] Avoid structured data sources with provider partitions (blog post)
- Modified Rules
- [DAX Expressions] Column references should be fully qualified
- Scope: Added 'Table Permissions'
- [Formatting] Hide fact table columns
- Simplified rule logic
- [Performance] Check if dynamic row level security (RLS) is necessary
- Simplified rule logic
- [Performance] Limit row level security (RLS) logic
- Simplified rule logic
- [Formatting] Add data category for columns
- Fixed rule logic
- [Performance] Measures using time intelligence and model is using Direct Query
- Simplified rule logic
- [Performance] Reduce usage of calculated columns that use the RELATED function
- Simplified rule logic
- [Performance] Reduce usage of long-length columns with high cardinality
- Updated rule logic to use Int64
- [DAX Expressions] Column references should be fully qualified
- New Rules
- 2021-06-13 Version 1.1.2
- Modified Rules
- [DAX Expressions] Use the DIVIDE function for division
- Updated the rule logic to not mistake comments for division
- [DAX Expressions] Use the DIVIDE function for division
- Modified Rules
- 2021-05-26 Version 1.1.1
- Modified Rules
- [DAX Expressions] Inactive relationships that are never activated
- Expanded the scope to include Calculation Items (#110)
- [DAX Expressions] Inactive relationships that are never activated
- Modified Rules
- 2021-05-20 Version 1.1 (make sure to read the blog post)
- New Rules
- [DAX Expressions] Filter column values with proper syntax
- [DAX Expressions] Fllter measure values by columns, not tables
- [DAX Expressions] Inactive relationships that are never activated
- [Maintenance] Perspectives with no objects
- [Maintenance] Calculation groups with no calculation items
- Modified Rules
- [Naming Conventions] Partition name should match table name for single partition tables
- Added Fix Expression (must use Tabular Editor 2.16.1 or higher)
- [Error Prevention] Calculated columns must have an expression
- New name: Expression-reliant objects must have an expression
- [Maintenance] Objects with no description
- New name: Visible objects with no description
- [Naming Conventions] Partition name should match table name for single partition tables
- Removed Rules
- [DAX Expressions] No two measures should have the same definition
- New Rules
- 2021-02-03 Version 1.0