Tabular Editor provides an intuitive hierarchical view of every object in your Tabular Model metadata. Columns, Measures and Hierarchies are arranged in Display Folders by default. You can edit properties of one or more objects, by (multi)selecting them in the tree. A DAX Editor with syntax highlighting lets you easily edit the expressions of Measures, Calculated Columns and Calculated Tables.
Tabular Editor 2 (TE2) is the original open source version. This is free to use and will continue to be supported. Tabular Editor 3 (TE3) is the commercial product version. It has a 30 day trial afterwards a paid license is required. This introduction covers TE2, but the material translates to TE3.
Website: https://tabulareditor.com/
TE2: https://github.com/otykier/TabularEditor/releases
Follow Along:
- Setup
- Tabular Object Model Hierarchy
- Best Practice Analyzer
- Advanced Scripting
- Calculation Groups
- Continue Your Journey
- Upgrade to the latest version of Power BI Desktop which supports Store datasets using enhanced metadata format.
- Navigate to the File menu and select Preferences
- Enable the settings:
- Allow unsupported Power BI features (experimental)
- Detect changes on local AS instance (experimental)
Important Note: Always create a backup of your PBIX file prior to editing to avoid any issues in the event of a corrupted model.
Source: Microsoft Docs
The Tabular Object Model (TOM) exposes native tabular metadata, such as model, tables, columns, and relationships objects. A high-level view of the object model tree, provided below, illustrates how the component parts are related.
From a logical perspective, all tabular objects form a tree, the root of which is a Model, descended from Database. Server and Database are not considered tabular because these objects can also represent a multidimensional database hosted on a server running in Multidimensional mode, or a tabular model at a lower compatibility level that does not use tabular metadata for object definitions.
- Open the Sales Demo (PBIX) file, navigate to the External Tools ribbon in Power BI Desktop and select Tabular Editor.
- On your local machine create a folder titled: Sales Demo
- Within Tabular Editor
- Navigate to File > Save to Folder... and select the above Sales Demo that was created.
- Navigate to the Sales Demo folder and review the outputs in comparison with the TOM hierarchy above.
- To view the full solution navigate to File > Save As.. and save the output model.bim (bim: business intelligence model), to your local machine to review.
Important Note: The underlying model.bim file can now be incorporated into your CI/CD pipelines for deployments with Azure DevOps. To deploy changes directly to existing datasets published in the Power BI service, enabling the XMLA read/write endpoint in the capacity settings and Power BI Premium is required. Once changes have been made to a dataset published in the service using the XMLA end point, a PBIX file will no longer be able to be downloaded.
Learn More About Data Modeling and Management Tools
The best practices rules are a collection of community contributions for Tabular Model development. They let you define global or model-specific rules using a simple expression language. At any time, you can check whether objects in your model satisfy the rules.
Website: https://github.com/TabularEditor/BestPracticeRules
Michael Kovalsky (Microsoft) blog posts: https://powerbi.microsoft.com/en-us/blog/author/mikova/
-
Navigate to the repository, https://github.com/TabularEditor/BestPracticeRules
-
Navigate to the BPARules-standard.json file and press the Raw button.
- Copy the web address in your browser (must match the below with the prefix raw) -
https://raw.githubusercontent.com/TabularEditor/BestPracticeRules/master/BPARules-standard.json
-
Within Tabular Editor:
- Navigate to Tools and select Manage BPA Rules...
- Within the Manage Best Practice Rules dialog:
- Press Add..
- Select Include Rule File from URL and press OK
- Paste the above BPARules-standard.json web address and press OK
-
Within Tabular Editor:
- Navigate to Tools and select Best Practice Analyzer... or press the hotkey (F10)
- Review the current list of objects needing attention based on the rules.
- Select the header Hide foreign key columns (11 objects)
- Press the Generate fix script icon to copy to the clipboard.
- In the Fix script generation dialog box prompt press OK.
-
Within Tabular Editor:
-
Within Power BI Desktop:
- Review the Orders table to confirm that all the applicable columns (CustomerID, SalesPersonID, Order Date and Expected Delivery Date) are now hidden.
- Right click any field and select Unhide All
-
Within Tabular Editor:
- In the External change detected dialog box press Yes
- Confirm that the fields hidden are now visible.
- Navigate to Tools and select Best Practice Analyzer... or press the hotkey (F10)
- Select the header Hide foreign key columns (11 objects)
- Press the Apply fix icon to instantly apply fixes.
- Press the Saves the changes to the connected database (Ctrl+S) button.
- Within Tabular Editor:
- Navigate to Tools and select Manage BPA Rules...
- Within the Manage Best Practice Rules dialog
- Select from the Rule collections: Rules on the local machine
- Press New rule... and insert the following values from the hash table below.
- Once completed press OK to save.
Key | Value |
---|---|
Name | Disable auto time intelligence |
ID | DISABLE_AUTO_TIME_INTELLIGENCE |
Severity | 1 |
Category | Performance |
Description | Navigate to the Power BI Desktop's Current File properties and disable the setting Auto date/time in Data Load. Note: To disable for all new files created in Power BI Desktop disable the setting Auto date/time for new files in the Global settings Data Load. |
Applies to | Model |
Rule Expression Editor | Tables.Any(Name.StartsWith("LocalDateTable_")) |
Minimum Compatability Level | CL 1200 (SQL Server 2016 / Azure AS) |
- Navigate to Tools and select Best Practice Analyzer... or press the hotkey (F10) to view the newly created rule.
Important Note: Changes to the model can be both read from and written to the Power BI dataset. Any changes within Tabular Editor will need to be saved back to the connected database.
Advanced Scripting, lets users write a script, to more directly manipulate the objects in the loaded Tabular Model, that can be saved as Custom Actions for easy invocation directly in the Explorer Tree.
Website: https://github.com/otykier/TabularEditor/wiki/Advanced-Scripting
Important Note:
- You can use CTRL+Z to undo or CTRL+Y to redo changes.
- The scripting language is C#
- Select the Advanced Scripting tab and enter the below script
Selected.Table.AddMeasure(
"Total Count of " + Selected.Table.Name,
"COUNTROWS('" + Selected.Table.Name + "')",
"Measurements"
);
Recommended Practice: Utilize a single quote in the event of a table name containing a space for the expression.
- Select the Orders table and then press the Run script (selection only) F5 button. ▶
- Within the Model Explorer navigate to the Orders table, the Measurements folder and select the Total Count of Orders measure.
- Review the following arguments from the script earlier in comparison with the Property Pages
Selected.Table.AddMeasure(
Argument1 // Name ,
Argument2 // DAX expression ,
Argument3 // Display Folder
);
- Press the Saves the changes to the connected database (Ctrl+S) button.
- Navigate to Power BI Desktop to confirm the new measure has been added to the file.
- With the Model Explorer focused, press CTRL+Z to undo actions until the folder and measure have been removed from the Orders table.
- Within the Advanced Scripting tab update the script to include a variable
var tableName = Selected.Table.Name;
Selected.Table.AddMeasure(
"Total Count of " + tableName,
"COUNTROWS('" + tableName + "')",
"Measurements"
);
- Select the Orders table and then press the Run script (selection only) F5 button. ▶
- Confirm within the Model Explorer in the the Orders table and the Measurements folder the the Total Count of Orders measure exists.
- Select the Customers and Employees table and press the Run script (selection only) F5 button. ▶
- An error will now be displayed stating The selection contains more than one object of type Table indicating only one active object can be selected.
- Within the Advanced Scripting tab select Samples, Tutorials and Loop through all selected tables
- Update the script to include the below:
foreach(var table in Selected.Tables) {
var tableName = table.Name;
table.AddMeasure(
"Total Count of " + tableName,
"COUNTROWS('" + tableName + "')",
"Measurements"
);
};
- Select the Orders, Customers, Employeees and Customer Transactions tables and then press the Run script (selection only) F5 button. ▶
- Press the Saves the changes to the connected database (Ctrl+S) button.
- Navigate to Power BI Desktop to confirm the new measure has been added to the file.
- Within the Advanced Scripting tab select Samples, Tutorials and Loop through all selected columns
- Update the script to include the below:
foreach(var column in Selected.Columns) {
column.Table.AddMeasure(
"Sum of " + column.Name,
"SUM(" + column.DaxObjectFullName + ")",
"Measurements"
);
}
Important Note: The DaxObjectFullName property provides the fully qualified name of the column for use in the DAX expression: 'TableName'[ColumnName].
- Select the following columns in the Sales Order Lines table and then press the Run script (selection only) F5 button. ▶
- Quantity
- Unit Price
- Picked Quantity
- Review the Measurements folder in the Sales Order Lines table to confirm the new measures have been added.
- Select the Model Explorer to focus and press Ctrl+Z to undo the above script.
- Update the script to include the below:
foreach(var column in Selected.Columns) {
column.Table.AddMeasure(
"Sum of " + column.Name,
"SUM(" + column.DaxObjectFullName + ")",
"Measurements"
);
column.Table.AddMeasure(
"Average of " + column.Name,
"AVERAGE(" + column.DaxObjectFullName + ")",
"Measurements"
);
}
- Select the following columns in the Sales Order Lines table and then press the Run script (selection only) F5 button. ▶
- Quantity
- Unit Price
- Picked Quantity
- Review the Measurements folder in the Sales Order Lines table to confirm the new measures have been added.
- Press the Saves the changes to the connected database (Ctrl+S) button.
A calculation group is a set of calculation items that are conveniently grouped together because they are variations on the same topic.
Within Tabular Editor:
- Navigate to the Calendar table's Date column and edit the Property Pages Hidden property to False.
- Right click the Tables object and select Create New and Calculation Group ALT+7
- Rename the New Calculation Group to Time Intelligence
- Change the Name column's, Name property to Time Calculation (Pro Tip: F2 for Edit Mode)
- Right click Calculation Items and select New Calculation Item, repeat the following three times.
- For each of the following insert the following expression:
Key | Value |
---|---|
New Calculation | CALCULATE ( SELECTEDMEASURE (), DATESMTD ( 'Calendar'[Date] ) ) |
New Calculation 1 | CALCULATE ( SELECTEDMEASURE (), DATESQTD ( 'Calendar'[Date] ) ) |
New Calculation 2 | CALCULATE ( SELECTEDMEASURE (), DATESYTD ( 'Calendar'[Date] ) ) |
- Individually select and rename each of the following Calcuation Items individually within the Property Page's Name property:
Key | Value |
---|---|
New Calculation | MTD |
New Calculation 1 | QTD |
New Calculation 2 | YTD |
- Select all three calculation items (MTD, QTD, YTD) to bulk update the Property Page's Format String Expression property to "$#,0.00"
- Press the Saves the changes to the connected database (Ctrl+S) button.
Within Power BI Desktop:
- Navigate to the Time Intelligence table, right click and select Refresh data
- Using a Matrix visual insert the following:
Key | Value |
---|---|
Rows | 'Calendar'[Date] |
Values | [Total Unit Price] |
Columns | 'Time Intelligence'[Time Calculation] |
PowerBI.Tips - Tabular Editor Playlist
SQLBI - Creating calculation groups in Power BI Desktop using Tabular Editor
SQLBI - Calculation Groups (Blog)
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.