bartekgraczyk / ModelAutoBuild

A framework for dynamically creating a tabular model

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Model Auto Build

Model Auto Build is a framework that dynamically creates a tabular model based on an Excel template. This framework is compatible for all destinations of tabular models - SQL Server Analysis Services, Azure Analysis Services, and Power BI Premium. This framework is also viable for both in-memory and direct query models.

Purpose

To provide a framework for business stakeholders and developers when initially outlining a model. When completed, the Excel template serves as a blueprint for the tabular model - akin to a blueprint for designing a building.

This framework speeds up the development time of the model once the blueprint has been laid out. Development time can be spent on more advanced tasks such as solving DAX challenges or complex business logic requirements.

Lastly, many people who are new to Power BI are more familiar with Excel. Since the framework is based in Excel it provides a familiar environment for such folks.

Instructions

1.) Download the following files from the ModelAutoBuild folder and save them to a single folder on your computer.

  ModelAutoBuild.xlsx
  ExcelToTextMaster.exe
  ModelAutoBuild.cs
  BlankModelTemplate.bim
  ModelAutoBuild_Example.xlsx (this file shows an example of a properly filled out ModelAutoBuild.xlsx file)

2.) Open the ModelAutoBuild.xlsx file.

3.) Populate the columns in each of the tabs, following the instructions within the notes shown on the header rows.

4.) Open the ModelAutoBuild.cs in a Text Editor (i.e. Notepad, Notepad ++, Sublime).

5.) On the first line of code, change the folderName parameter to the folder that contains all of the files in Step 1.

Here is an example:

var folderName = @"C:\Documents\ModelAutoBuild";

6.) Save and close the ModelAutoBuild.cs file.

7.) Open the Command Prompt.

8.) Run the ExcelToTextMaster program as shown below. The first parameter is the ExcelToTextMaster program, the second is the file path of the ModelAutoBuild Excel file.

Here is an example:

"C:\Documents\ExcelToTextMaster.exe" "C:\Documents\ModelAutoBuild\ModelAutoBuild.xlsx"

9.) Make sure you have Tabular Editor installed on your computer. Here is a link to download it: https://github.com/otykier/TabularEditor/releases

10.) Run the following in the Command Prompt. Ensure that the location of Tabular Editor matches where it is stored on your computer. Also ensure that the folder used in the -S and -B parameters is the same as the folder from Step 1.

start /wait /d "C:\Program Files (x86)\Tabular Editor" TabularEditor.exe "C:\Documents\ModelAutoBuild\BlankModelTemplate.bim" -S "C:\Documents\ModelAutoBuild\ModelAutoBuild.cs" -B "C:\Documents\ModelAutoBuild\NewModel.bim"

After completing Step 10, your new .bim file is ready. It is in the location specified under the -B parameter in Step 10. It may be opened in Tabular Editor.

If you want to deploy the model to SQL Server Analysis Services or Azure Analysis Services, view the instructions here: https://github.com/otykier/TabularEditor/wiki/Command-line-Options

If you want to deploy the model to Power BI Premium, view the instructions here: https://github.com/TabularEditor/tabulareditor.github.io/blob/master/_posts/2020-06-02-PBI-SP-Access.md

Additional Notes

  • It is not necessary to fill in all the details of the model. For example, the Expression (DAX) and other such elements may be created afterwards. The goal of this framework is not to create a completed model per say but to quickly and intelligently build the foundation.

  • If you want a column to be a calculated column, simply add in the DAX in the Expression column. Columns that have DAX expressions will automatically become calculated columns. If there is no expression they will default to a data column (where you must enter a source column). Note of caution: try your best to avoid calculated columns. If in doubt, view Best Practice #6 within this post: https://www.elegantbi.com/post/top10bestpractices.

  • The partition queries generated by this framework are in the following format (example below is of a fact table). This is a best practice and ensures no logic is housed within the partition query.

    'SELECT * FROM [SchemaName].[FACT_TableName]'

  • This tool is capable of formatting the DAX for all the measures in your model. Out of the box this is commented out. If you want the DAX to be formatted just uncomment the following line within the .cs script:

    o.Expression = FormatDax(o.Expression);
    

Version History

  • 2020-06-11 Version 1.0.0 released on GitHub.com
  • 2020-06-16 Version 1.1.0 released (added Roles and Row Level Security)
  • 2020-06-24 Version 1.2.0 released (added support for Calculated Columns)
  • 2020-07-06 Version 1.3.0 released (added support for Hierarchies)

About

A framework for dynamically creating a tabular model

License:MIT License


Languages

Language:C# 100.0%