Extract Table Relationships, m expressions, and DAX expressions from Power BI template.
Project description
PyDaxExtract
Extract table relationships and m and DAX expressions from a Power BI template file.
Power BI files in the pbix and pbit formats are basically zip archives containing other compressed data.
The DataModel file in a pbix file contains all the DAX expressions created when processing data. All data is saved in the Xpress9 format, which is a proprietary compresson method optimized to dump memory to disk and vice-versa, with encryption and all kinds of other wonderful features which will break you heart if you try to get a peek inside.
Fortunately, if one saves a Power BI workbook as a template, the table relationships, m expressions and DAX expressions are now saved in the DataModelSchema object, which is unencrypted and requires only a bit of fiddling to remove.
This module, and command-line script are intended to help with that fiddling, and to aid users in serializing work done in an otherwise fairly opaque binary format. Here's hoping it's useful to you.
At this point, there appears to be no way to automate exporting pbix files as pbit, so you'll have to do that the usual way.
This script will work as long as it does, given the rate of churn (I mean development) in Power BI. Good luck!
Usage
Module
from pathlib import Path
from dax_extract import read_data_model_schema
pbit_path = Path("/path/to/my_awesome.pbit")
data = read_data_model_schema(pbit_path)
Command Line
usage: daxextract.py [-h] [--dump-json] [--dump-expressions] [--write-dax-csv]
[--write-powerquery-csv] [--write-relationships-csv]
pbit_path
Extract PowerQuery (m) / DAX expressions from Power BI template file.
positional arguments:
pbit_path Path to .pbit file.
optional arguments:
-h, --help show this help message and exit
--dump-json Write full dump of DataModelSchema to stdout in json
format.
--dump-expressions Write DAX and PowerQuery (m) expressions to stdout in
json format.
--write-dax-csv write csv file containing DAX measures and metadata in
csv format.
--write-powerquery-csv
write csv file containing PowerQuery expressions and
metadata in csv format.
--write-relationships-csv
write csv file containing table relationships in csv
format.
Installation
pip install pydaxextract
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file PyDaxExtract-0.2.1.tar.gz.
File metadata
- Download URL: PyDaxExtract-0.2.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61244cc7cace51aaf7f0e8472ee704b8036197a8fcd396ed67ff51f35a82513a
|
|
| MD5 |
b21ad22824a308469194566e10c8cf30
|
|
| BLAKE2b-256 |
ca1fedfd0a4c8698963eedc1cbd7a50a7d5dd01e5ff535dbbddeaa0139142db5
|
File details
Details for the file PyDaxExtract-0.2.1-py3-none-any.whl.
File metadata
- Download URL: PyDaxExtract-0.2.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23940f0ee0c1462111b617eaabd6da6cc1ae0d789d2cf8b14b251ddb0683660b
|
|
| MD5 |
6b64a62a89b7e992488285b382a4e608
|
|
| BLAKE2b-256 |
117e2d0ac3141ad17caace47a66bc7b5bf66ed0df8a6de385d786ab058b95ab1
|