Quantcast
Channel: Tabular – SQLBI
Viewing all articles
Browse latest Browse all 227

Offline model editor experience for Power BI

$
0
0

Professional BI developers using Analysis Services and advanced users working with Power BI share a common pain. Their productivity editing a large data model is much lower than what you might expect in 2017. There are many reasons for that. The most important ones are the automatic update of the model in the workspace for Visual Studio, and the UI limitations of Power BI. I am pretty sure that Microsoft is working on this and will came up with a solution in a hopefully not too distant future.

However, there are alternatives available today. Productivity is a daily cost for everyone in this business. Even if what I am going to describe here is not fully supported (more on this later), I think that the cost benefit is so big for certain scenarios that several users will consider managing the risk.

The tool I am going to describe is Tabular Editor. This free and open source tool (which main author is Daniel Otykier) is based on the official TOM library to manage a Tabular data model. It is totally supported when used with Analysis Services 2016 and 2017. If you have never seen Tabular Editor, you should try it. I will cover some of its features in future articles. However, the goal of this post is to describe how to use Tabular Editor with a Power BI model.

Let me start with a big disclaimer.

Using Tabular Editor to modify a Power BI Desktop model is not supported. You will do this at your own risk. You should create a backup of your Power BI file. Any change you apply to Power Bi might corrupt your model, your data, and your reports in a way that will require you to delete the file, losing all your work. If something bad happen, do not call Microsoft support. They will not be able to help you. You can file an issue for Tabular Editor, but Tabular Editor developers will not be able to recover your data. Thus, create a backup first. Maybe two, just in case.

Well, now that you made two copies of your Power BI file, you can create a third one, and then continue to read.

Editing a PBIT file with Tabular Editor

The first and currently preferred way to edit a Power BI model is to edit it as a template (PBIT) file. The PBIT file does not have any data, so there is a lower chance that you change something that can invalidate the model. Moreover, if something goes wrong, probably you will not be able to open the file. Because the template is saved starting from an existing PBIX file, it is also harder to break the original data and model, which are included in the original PBIX file that you usually do not override saving a PBIT file.

Using Tabular Editor, you should edit existing tables and columns because the binding to a data source is something that is difficult to generate in a consistent way using this offline experience. The main usage of Tabular Editor is to maintain measures and attributes of existing tables and columns in a productive way when you apply many changes to a data model. For example, modifying a format string using multiple selection is an easy and efficient task in Tabular Editor, whereas it requires several repetitive manual operations in Power BI.

This is the sequence you should use for this scenario:

  1. Open the PBIX file that you want to modify in Power BI (e.g. Model.pbix)
  2. Use File / Save As and save the file as a Power BI template (e.g. Model.pbit)
  3. Open Tabular Editor and use the File / Open / From File menu to open the Power BI template file you saved in the previous step.
  4. Edit the model in Tabular Editor. Do not make changes that could break the model. Tabular Editor hides properties that are certainly not supported by Power BI Desktop. Nevertheless, any set of changes you apply using this technique might result in an invalid model without any warning provided by Tabular Editor.
  5. Once you complete the edits in Tabular Editor, save the file with File / Save or File / Save As using a Power BI Template file type (e.g. NewModel.pbit). You might export to a .BIM file for Analysis Services at this point, but you should be able to fix data sources that are not supported “as is” in Analysis Services 2016/2017. Note: The import from Power BI features available in the Web Designer of Azure Analysis Services performs these conversions for you.
  6. Open the Power BI Template file in Power BI (e.g. NewModel.pbit). Power BI populates all the tables of the model by reading data from the data source. You need a connection to the data source to complete this step.
  7. Save the model populated with data using the File / Save or File / Save As menu in Power BI. Because the model is new and untitled, you must specify a file name (e.g. NewModel.pbix). Please note that if you override an existing PBIX file, you will lose previous model and data. You do not want to lose a backup of the previous version of model and data, so it is a good idea to use a new file name instead of overriding an existing one.

Tabular Editor should disable several features that are likely to break the data model in Power BI. For this reason, you should not do the following (and the Tabular Editor UI should also disable these features when you edit a Power BI template file):

  • Edit Display Folder property
  • Add/Remove Data Columns
  • Add/Remove Data Tables
  • Manipulate data sources

The features hidden by Tabular Editor can be enabled by checking the “Allow Unsupported Power BI Features (Experimental)” checkbox in the Tabular Editor Preferences dialog box. I suggest you to not do that.

Editing a model opened in Power BI Desktop

The second way to edit a Power BI model is connecting to the underlying in-memory data model, which is basically the same engine used by Analysis Services that can be manipulated by using the TOM library. Tabular Editor can use that connection, too, just like DAX Studio. However, this technique is very dangerous for your model and report, because the Power BI user interface is not aware of the underlying changes applied to the data model.

In theory, this technique does not require to refresh the entire data model, because the engine takes care to invalidate the data only when the change applied to the model requires a full refresh of the table. However, the lack of synchronization between the Power BI UI and the underlying data model is a big risk that I would avoid. The only reason why I am describing this technique is that I want to avoid that someone will “discover” that, without realizing the big risks involved.

If you want to experiment this technique, one way to refresh the metadata in the UI after you completed an edit online in a Power BI Desktop file using Tabular Editor is to Refresh all the tables of the data model. Before Power BI starts reading data from the data sources, there is a complete refresh of the Fields list in the user interface. At that point, if you cancel the data refresh before it completes, if the data model is still valid you have a working copy of the Power BI model with the “old” data. Canceling the refresh does not remove the previous data, but the synchronization of the Power BI user interface is already complete at that point.

This is the sequence you should use to connect Tabular Editor to a model opened in Power BI Desktop:

  1. Create a backup of the PBIX file that you want to modify in Power BI (e.g. ModelOriginal.pbix from Model.pbix).
  2. Open the PBIX file that you want to modify in Power BI (e.g. Model.pbix).
  3. Open Tabular Editor and use the File / Open / From DB menu.
  4. In the Local Instance combo box of the Connect to Tabular Server dialog box, select the Power BI window containing the model you want to edit and then click OK.
    Note: Tabular Editor 2.6.6492 version does not recognize the windows of Power BI Desktop installed from Windows Store. This should be fixed in an upcoming update of Tabular Editor.

  5. Edit the model in Tabular Editor. Do not make changes that could break the model. Tabular Editor hides properties that are certainly not supported by Power BI Desktop. Nevertheless, any set of changes you apply using this technique might result in an invalid model without any warning provided by Tabular Editor.
  6. Every time you complete a set of changes in Tabular Editor, save them in the model using File / Save.
  7. The user interface of Power BI does not reflect the updates you made to the data model so far. You can force a refresh of the user interface by clicking the Refresh button in the Home ribbon of Power BI. You can also cancel the refresh operation immediately after you requested it. Even if the data will be untouched, the user interface should have been aligned to the updates made to the data model so far.
  8. Save the Power BI file using File / Save As. Using a different name could be a good idea, so you do not override existing data and you have different versions of the model in different files. During the development this could be a very good idea if you need to roll back to a previous version.

Please, remember that this technique is completely unsupported (as of October 2017) and it could break your reports in Power BI.

Recap

Advanced users and developers need a more productive environment when they manage large and complex models. The issue faced in Power BI are the very same of Analysis Services Tabular, so also the tools could be the same.

Tabular Editor is an open source project that provides a very productive user interface. It is not a replacement of existing editors, which show preview of data and measures at any time and are always synchronized. I think to Tabular Editor as a complement to the existing editors, which I want to use to create new models from scratch and to apply small changes. Whenever I want to edit many measures, I prefer to use Tabular Editor.

Using Tabular Editor to edit a Power BI file is possible, but not supported. Modifying the template PBIT file is potentially safer, but requires more interaction to see the result of the changes applied to the model.  Modifying a model opened in Power BI Desktop model is appealing and potentially more productive than modifying the template file, but there is a higher chance to break the model.

Call to action for open source support

I understand that the number of advanced users needing these features is a small niche compared to the larger audience of Power BI users. Despite the relative higher importance of advanced users, who create models consumed by many people, any effort for developing these tools is probably overridden in priority by new and shining features targeted to a larger audience. It is the market, the same market that is rewarding Power BI with a large success, so prioritizing features other than an advanced editor if the right thing to do. I agree.

However, it is possible to do more, and I am wondering why Microsoft will not “adopt” an open source approach also in this space. As a company, Microsoft is very committed to open source in many areas. I think that Visual Studio Code is one of the best examples of the success of this effort, reaching an audience much larger than existing Microsoft customers. I cannot say that the same effort is present in the Business Intelligence area (let me use this name – after all, it is the meaning of BI in Power BI). For example, the custom visuals in Power BI are second class citizens. There are good reasons for that, mainly because of customer support. But….

I cannot find a good reason to justify a complete absence of open source initiatives, or at least support to existing ones, in the development tools for Business Intelligence (including Power BI, Analysis Services, Reporting Services, and Integration Services, if you want to consider the full spectrum of it). Supporting open source tools like Tabular Editor, DAX Studio, and many others that the community might help to create and maintain is a win-win scenario. I am convinced that the effort required to Microsoft to provide API and/or documentation would generate a much higher return in the value of the tools that will be developed thanks to such investment.

If you agree, it is time to raise your voice. In 2015, when Power BI Desktop was called Power BI Designer, I submitted the request for an API for Power BI Desktop to Microsoft. This idea is currently ranked as 28th in the Power BI Ideas, with more than 1,100 votes. Any significant increase to this number will send a message that will be read by Microsoft executives, too.

If you agree, vote now. If you already voted, use the comments.

We need to put pressure on Microsoft.


Viewing all articles
Browse latest Browse all 227

Trending Articles