Giter Club home page Giter Club logo

minimodelbuilder's Introduction

Mini Model Builder

Mini Model Builder is a tool that allows you to customize a 'mini model' based on an existing tabular model. This tool runs inside of Tabular Editor's Advanced Scripting feature. This tool is compatible for all destinations of tabular models - SQL Server Analysis Services, Azure Analysis Services, and Power BI Premium (using the XMLA endpoint). This tool is also viable for both in-memory and direct query models.

Mini Model Builder

Purpose

Call them what you want - 'micro cubes', 'mini models', 'derivative models' - this tool is designed to simplify the process of creating a 'mini model'. It is also designed with the intention of being used by a broader audience than just the tabular developer community.

Running the Tool

1.) Download the following file to your computer.

  MiniModelBuilder.cs

2.) Open Tabular Editor.

3.) Connect to your model.

4.) Paste the MiniModelBuilder.cs script inside the C# script window within Tabular Editor.

5.) Click the 'Play' button (or press F5).

Creating the 'Mini Model'

After you set up a mini model using the Mini Model Builder tool and save your model to a .bim file, you can use the command line code below to generate and deploy the mini model.

1.) Download and save the following file to your computer.

   MiniModelBuilder_Create.cs

2.) Run the following code in the command prompt below (filling in the <parameters>) according to the variety of tabular you are using.

Since each of the scripts below uses an Environment Variable (set miniModelName=), there is no need to duplicate the MiniModelBuilder_Create.cs file for each mini model. The same MiniModelBuilder_Create.cs file can be referenced for creating all mini models. Setting the 'miniModelName' Environment Variable instructs the code which mini model to create.

set miniModelName=<Mini Model Name>
start /wait /d "C:\Program Files (x86)\Tabular Editor" TabularEditor.exe "<Master Model.bim file>" -D "<Server Name>" "<Mini Model Database Name>" -S "<C# Script File Location (MiniModelBuilder_Create.cs)>"
set miniModelName=<Mini Model Name>
start /wait /d "C:\Program Files (x86)\Tabular Editor" TabularEditor.exe "<Master Model.bim file>" -D "Provider=MSOLAP;Data Source=asazure://<AAS Region>.asazure.windows.net/<AAS Server Name>;User ID=<xxxxx>;Password=<xxxxx>;Persist Security Info=True;Impersonation Level=Impersonate" "<Mini Model Database Name>" -S "<C# Script File Location (MiniModelBuilder_Create.cs)>"

Running this in Power BI Premium requires enabling XMLA R/W endpoints for your Premium Workspace. An additional requirement is setting up a Service Principal.

set miniModelName=<Mini Model Name>
start /wait /d "C:\Program Files (x86)\Tabular Editor" TabularEditor.exe "<Master Model.bim file>" -D "Provider=MSOLAP;Data Source=powerbi://api.powerbi.com/v1.0/myorg/<Premium Workspace>;User ID=app:<Application ID>@<Tenant ID>;Password=<Application Secret>" "<Mini Model Premium Dataset>" -S "<C# Script File Location (MiniModelBuilder_Create.cs)>" 

Instructions for using the program

  • For navigation, either use the 'Next' button or click directly on a particular step using the Navigation pane.
  • Only Step 1 is necessary. All other steps are optional.
  • Always click the 'Save' button after making a change. If the 'Save' button is not pressed, your changes will not be saved.

Features

  • Step 1: Select which objects you need in your mini model. Object dependencies are automatically added to your mini model.
  • Step 2: Simply toggle to hide or unhide objects (tables, measures, columns, hierarchies) within your mini model. If an object shows as gray in this step it will be hidden in the mini model. If an object shows in black, it will be visible in the mini model.
  • Step 3: Update the DAX for measures or calculated columns in your mini model.
  • Step 4: Remove non-necessary partitions from multi-partitioned tables in your mini model.
  • Step 5: Remove non-necessary perspectives.
  • Step 6: Perform a find-and-replace within your partition queries. This allows you to easily repoint your tables/partitions to a different schema in your data warehouse.
  • Step 7: Update role members and model permission for your mini model.
  • Step 8: Update the row level security (RLS) for any role and table that has RLS filters within the original model.
  • Step 9: Update tables to point to a different data source (choosing among the data sources within the original model).
  • Step 10: Filter your model based on column values. The column filters should be placed on dimension tables. These filters will be applied to the related fact tables as well (based on existing relationships).
  • Step 11: Set aggregations to minimize row counts in your mini model. Use the light bulb icon to recommend summarizations for each of the columns in your table. Aggregations are only for tables on the 'from-side' of a relationship (in other words, Fact tables).
  • Summary: Shows a full summary of all the differences between the original model and the mini model.
  • Blue icon indicates an object is different in the mini model as compared to the original model.
  • Automatically updates perspectives and annotations to ensure your mini model is created exactly as specified.
  • All relationships and model integrity is passed on from the original model to the mini model.
  • In the Summary view, the 'Script' button will output a C# file to your desktop which contains all the instructions for creating your mini model. This can be executed in the 'Advanced Scripting' window against the original model.

Requirements

  • Tabular Editor version 2.12.1 or higher. This tool is not compatible with Tabular Editor 3.
  • Compatible for SQL Server Analysis Services, Azure Analysis Services, and Power BI Premium models.
  • Compatible for tabular models using Import-mode, Direct Query mode, and Composite models.
  • Make sure to click the 'Save' button within each page of the Mini Model Builder after making changes.
  • To use the 'Filter Column Values' step, you must be live-connected to an Analysis Services model.
  • To use either the 'Filter Column Values' or 'Set Aggregations' steps, your data source must be a SQL-type source and partition queries must start with 'SELECT * FROM ...'.

Version History

  • 2021-04-23 Version 1.0.2 released
  • 2021-03-08 Version 1.0.1 released
    • MiniModelBuilder_Create.cs now uses an Environment Variable so the script is completely reusable for all mini models.
  • 2020-12-01 Version 1.0.0 released on GitHub.com

minimodelbuilder's People

Contributors

m-kovalsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

minimodelbuilder's Issues

Tabular Editor 3 Support?

I really like the Mini Model builder (used with TE2) but get script errors when attempting to use this in Tabular Editor 3. Is there any Tabular Editor 3 support for this currently, and if not is any planned? Thanks.

Selecting other objects outside the created minimodel

Hi m-kovalsky,

After creating a minimodel cube, it is not possible to add other not selected objects. To achieve this, we have to redo the selection and creation of the minimodel cube.

I'v done a little modification and set all the objects from the model on false first and then add the selected objects in the export.
Is there another way to solve this?

Maybe I can create a pull request for this?

kind regards,
marioc

Deselected columns are included when generating the mini model from script

Hi,

I want to make a mini model through the interface, and I select only a subset of columns from a certain table. In the model, this is correct, only the selected columns are included in the perspective.

However, the generated script includes Model.Tables["table name"].InPerspective[perspName] = true;, followed by a statement for each included column. However, the entire table seems to be added to the perspective due to this first statement, including the deselected columns. So when I try to recreate the mini model using the script, it differs from the mini model that was created through the interface, since it includes too many columns.

Is this the expected behaviour? Is there a way to bypass this, or am I overlooking a step to fix this?

A second issue is the fact that hidden columns don't show up in step 1 in the interface, meaning I can't choose to include/exclude these in the mini model, and they seem to be added automatically via the script (due to the problem described earlier), or excluded automatically through the interface.

Is there a way to avoid this, or should I add/remove them to/from the perspective manually using a script?

Many thanks,
Eva

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.