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
Metadata
Release files for PyDaxExtract 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| PyDaxExtract-0.2.1.tar.gz | 5.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| PyDaxExtract-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.0 kB
Release files / PyDaxExtract-0.2.1.tar.gz
| Download URL | PyDaxExtract-0.2.1.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61244cc7cace51aaf7f0e8472ee704b8036197a8fcd396ed67ff51f35a82513a
|
|
BLAKE2b-256 checksum How to use checksums |
ca1fedfd0a4c8698963eedc1cbd7a50a7d5dd01e5ff535dbbddeaa0139142db5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / PyDaxExtract-0.2.1-py3-none-any.whl
| Download URL | PyDaxExtract-0.2.1-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23940f0ee0c1462111b617eaabd6da6cc1ae0d789d2cf8b14b251ddb0683660b
|
|
BLAKE2b-256 checksum How to use checksums |
117e2d0ac3141ad17caace47a66bc7b5bf66ed0df8a6de385d786ab058b95ab1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for PyDaxExtract 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.