Metadata-Version: 2.4
Name: trailsbi
Version: 1.7.0
Summary: End-to-end data lineage, model health and AI readiness for Power BI projects (PBIP). Runs offline.
Author: TrailsBI
License-Expression: Apache-2.0
Project-URL: Homepage, https://trailsbi.com
Project-URL: Source, https://github.com/trailsbi/trailsbi
Project-URL: Issues, https://github.com/trailsbi/trailsbi/issues
Keywords: power bi,pbip,pbir,tmdl,lineage,best practice analyzer,copilot
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Documentation
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Dynamic: license-file

<p align="center">
  <a href="https://trailsbi.com"><img src="https://raw.githubusercontent.com/trailsbi/trailsbi/v1.7.0/docs/images/readme-hero.jpg" width="100%" alt="TrailsBI: End-to-end Data Lineage, Model Health and AI Readiness for Power BI. One report that maps every source, table, column, measure, visual and page, and tells you what to fix."></a>
</p>

<p align="center">
  <a href="https://trailsbi.com"><b>Website</b></a>
  &nbsp;·&nbsp; <a href="#get-started"><b>Get started</b></a>
  &nbsp;·&nbsp; <a href="https://trailsbi.com/samples"><b>Sample Reports</b></a>
  &nbsp;·&nbsp; <a href="https://www.youtube.com/watch?v=HQTlUTrLqag"><b>Demo video</b></a>
</p>

<p align="center"><sub>* Power BI is a trademark of Microsoft. TrailsBI is not affiliated with or endorsed by Microsoft.</sub></p>

## Trails for Power BI

TrailsBI reads a Power BI project saved as PBIP (TMDL and PBIR files) and builds one
self-contained HTML page you can open in any browser. It runs entirely on your machine:
no sign-in, no upload, no telemetry.

<a href="https://www.youtube.com/watch?v=HQTlUTrLqag"><img src="https://raw.githubusercontent.com/trailsbi/trailsbi/v1.7.0/docs/images/demo-poster.jpg" width="640" alt="Watch the TrailsBI demo on YouTube: what breaks if you change a measure, answered on Microsoft's Competitive Marketing Analysis sample"></a>

**[Watch the demo on YouTube](https://www.youtube.com/watch?v=HQTlUTrLqag)**: what breaks if you change a measure, answered on Microsoft's Competitive Marketing Analysis sample.

## Everything about your Reports and Semantic Models

### Lineage - Follow any field from source to visual

- Pick a column or measure and see every data source, table and measure it depends on, in navy.
- Everything built on it, down to the visuals and pages, lights up in teal.
- Compact cards for the whole picture, detailed cards with usage counts when you need them.
- Switch to **Graph** to see the whole lineage in graph view, from the sources in the middle through tables to pages and visuals.
- Measures we add in live-connected reports are also tracked and show apart from the model's.
- Point at any DAX or Power Query function in the code for its syntax, a short description and a link to Microsoft Learn.

<img src="https://raw.githubusercontent.com/trailsbi/trailsbi/v1.7.0/docs/images/view-lineage.jpg" width="100%" alt="TrailsBI Lineage view on Microsoft's Human Resources sample">

<table>
<tr>
<td width="50%" valign="top">
<h3>Model - Every table, column, measure and relationship</h3>
<img src="https://raw.githubusercontent.com/trailsbi/trailsbi/v1.7.0/docs/images/view-model.jpg" width="100%" alt="TrailsBI Model view on Microsoft's Retail Analysis sample">
</td>
<td width="50%" valign="top">
<h3>Reports - What each page and visual actually uses</h3>
<img src="https://raw.githubusercontent.com/trailsbi/trailsbi/v1.7.0/docs/images/view-reports.jpg" width="100%" alt="TrailsBI Reports view on Microsoft's Regional Sales sample">
</td>
</tr>
<tr>
<td width="50%" valign="top">
<h3>Health - Best Practice Analyzer, without the setup</h3>
<img src="https://raw.githubusercontent.com/trailsbi/trailsbi/v1.7.0/docs/images/view-health.jpg" width="100%" alt="TrailsBI Health view on Microsoft's Store Sales sample">
</td>
<td width="50%" valign="top">
<h3>AI Readiness - Is the model set up the way Copilot needs?</h3>
<img src="https://raw.githubusercontent.com/trailsbi/trailsbi/v1.7.0/docs/images/view-ai-readiness.jpg" width="100%" alt="TrailsBI AI Readiness view on Microsoft's Competitive Marketing Analysis sample">
</td>
</tr>
</table>

## Get started

1. In Power BI Desktop, save your report as a Power BI project: **File > Save as > Power BI project (.pbip)**.
2. Install TrailsBI (Python 3.9 or later, no other dependencies):

   ```
   pip install trailsbi
   ```

   Or

   ```
   uv tool install trailsbi
   ```

3. Run it on your project:

   ```
   trailsbi "D:\Reports\Sales\Sales.pbip"
   ```

   This writes `TrailsBI Report - Sales - 2026-10-04 16-47.html` (with the current date and time) to the current folder. Open it in any browser.

Options:

```
trailsbi [PROJECT ...] [-o OUTPUT] [--open] [--embed] [--filter FILE] [--list] [-w NAME] [-m NAME] [-r NAME] [--with-reports] [--split]

  PROJECT       a .pbip file, the folder that holds it, a .Report folder, or a folder with several projects for a workspace page; give several folders to read several workspaces together (default: the current folder, so `trailsbi` alone works inside a project)
  -o, --output  where to write the page: a file name, which is also the name the page shows, or a folder for the default name (default: "TrailsBI Report - <project> - <date time>.html" here, named after the semantic model when you build just one)
  --open        open the page in your browser when it is ready
  --embed       show the report inside Power BI: adds a hidden TrailsBI table to the model and a TrailsBI page with the visual to the report (see below). Writes the HTML page only with -o or --open
  --filter      a JSON file with "scope" (which semantic models and reports to build, as the Scope menu saves it) and "filter" (reports, pages and visuals to include or exclude, as Cleanup saves it); see Cleanup below

  In a workspace folder (several reports and models), without these the whole folder is built:
  --list        list the semantic models and reports in the folder, then stop
  -w, --workspace  build the reports and models of this workspace
  -m, --model   build this semantic model
  -r, --report  build this report
  --with-reports  also build every report on the chosen semantic models
  --split       write one page per semantic model with the reports that use it, into the folder -o names (default: a new folder in the current folder)
```

### Workspace lineage

Point TrailsBI at a folder that holds several reports and semantic models, such as the Git folder a Power BI or Fabric workspace syncs to, and it builds one page for all of them:

```
trailsbi "D:\Git\Sales workspace"
```

- A **Workspace** map shows every data source, semantic model and report in the folder, in columns from data source to report, with lines for what feeds what. 
- Reports live-connected to a model that the folder also holds are joined to it, so one change to a model shows everything it touches in every report.
- **Scope** in the toolbar picks the semantic models and reports that the lineage, the model, the reports and the findings show. **Save Scope** saves it as a filter file, so you can build just that with `--filter`.

To build part of a folder, list what it holds and pick by name (wildcards work):

```
trailsbi "D:\Git\Sales workspace" --list
trailsbi "D:\Git\Sales workspace" --model "Sales*" --with-reports
trailsbi "D:\Git\Sales workspace" --report "Finance/Monthly" --report "Margin Check"
```

#### Several workspaces

If your Reports and their semantic models lives in different workspaces, give TrailsBI each workspace's folder and it builds them as one page, with the reports joined to their models:

```
trailsbi "D:\Git\Sales Reports" "E:\Repos\Sales Datasets"
trailsbi "D:\Git\*"
```

- A report finds its model by the model's name and the workspace its connection names (`powerbi://api.powerbi.com/v1.0/myorg/Sales Datasets`), so a Dev and a Prod copy of the same model are told apart.
- `--list` groups by workspace too, and `--workspace NAME` builds one workspace (add `--with-reports` for the reports on its models from the other workspaces).

To hand each model's owner their own page, split the workspace into one page per semantic model with the reports that use it, wherever those reports live. Reports on models the folders don't hold get a page per published model:

```
trailsbi "D:\Git\Sales Reports" "D:\Git\Sales Datasets" --split -o "D:\Lineage pages"
```

`--embed` still works on one report at a time.

### Cleanup: leave test or dev pages out

Power BI projects collect throwaway work: test pages, copies of pages, scratch reports and debug visuals. Cleanup leaves them out of the whole analysis, so Lineage, Model, Reports, Health and AI Readiness cover only what is real. Tables, columns and measures that only the left-out items used then show in Health as unused, ready to remove from the model.

1. Open the page, go to **Reports** and click **Cleanup**.
2. Choose **Leave out marked** or **Keep only marked** (for example, "these four pages are live, everything else is a test").
3. Mark reports, pages and visuals with their buttons, by clicking visuals on the canvas, or in **List View**, which has every report, page and visual with a search box.
4. Click **Save Filters** and build again with it:

   ```
   trailsbi "D:\Git\Sales workspace" --filter "Sales workspace filter.json"
   ```

The page then has a **Filter** chip in its toolbar. It opens a summary: what was analysed, each rule and what it matched, and everything left out. Cleanup on that page starts from the same marks, so you can change them and save again.

- Report names match the way `--report` does. Page names are the names Power BI shows. Visual names are the names TrailsBI shows: the visual's title, or its type and number on the page ("Card 2"). Case doesn't matter, and `*` and `?` are wildcards.
- Leaving out a report leaves out its pages; leaving out a page leaves out its visuals. Keeping a visual keeps its page and report, but not the rest of the page. A report with every page left out is left out too.

### Embed it in Power BI

The [TrailsBI visual](https://github.com/trailsbi/trailsbi-visual) (preview) shows the same five views inside a Power BI report. It reads them from a hidden `TrailsBI` table that `--embed` writes into the semantic model.

1. Close the project in Power BI Desktop, then run:
   `trailsbi "D:\Reports\Sales" --embed`
2. Open the project and refresh (**Home > Refresh**) so the new table loads.

It also adds a **TrailsBI** page to the report, hidden in view mode, with the visual on it and its fields already set. The visual is saved inside the report, so there is nothing to import.

The page needs a report saved in the PBIR format (Power BI Desktop's default for projects since 2025). For an older report, `--embed` writes the table and says so; add the visual yourself:
download `TrailsBI.pbiviz` from the visual's
[latest release](https://github.com/trailsbi/trailsbi-visual/releases/latest), import it (Visualizations pane: **...** > **Import a visual from a file**) and add it to a page. In the Data pane, right-click and turn on **View hidden**, then drag **TrailsBI > Chunk** onto the visual.

Run `--embed` again whenever the model or report changes, then refresh. It replaces the table (even if you renamed it) and never adds a second one. It keeps the TrailsBI page as you left it and brings the visual in the report up to date. TrailsBI leaves its own table, page and visual out of the analysis.

The table holds the model's names, DAX and data source addresses, so anyone who can open the report can read them in the visual. Embed it only where that is allowed.

### Single file

Each [release](https://github.com/trailsbi/trailsbi/releases/latest) also has `trailsbi.pyz`, the whole tool in one file: `python trailsbi.pyz "D:\Reports\Sales"`.

## Common Installation Issues

### 1. Windows: "'trailsbi' is not recognized"

When Python comes from the Microsoft Store or the Python install manager, pip puts the `trailsbi` command in a Scripts folder that is not on your PATH. pip warns about it during the install, and running `trailsbi "pbip-project-path"` returns `'trailsbi' is not recognized`.

Fix:
  - Add that Scripts folder to your own PATH once. [Setup](https://trailsbi.com/setup/)

## Privacy and security

- Reads metadata files only. Never opens `cache.abf` or any imported data.
- Makes no network calls and sends no telemetry.
- Read-only: never writes to your project files, except the `TrailsBI` table when you ask for it with `--embed`.
- The page is one HTML file with no external scripts, fonts or images.

See [SECURITY.md](SECURITY.md) for details.

## Develop

```
git clone https://github.com/trailsbi/trailsbi
cd trailsbi
python -m pip install -e . pytest "ruff==0.16.10"
python -m pytest
ruff check . && ruff format --check .
```

The page script is also linted with the rules Microsoft applies to Power BI custom visuals:
`npm install --no-save eslint@9 eslint-plugin-powerbi-visuals && npx eslint src/trailsbi/web/js`.

[CONTRIBUTING.md](CONTRIBUTING.md) explains how the code is laid out.

## Licence

Apache License 2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).

## Trademarks

Power BI is a trademark of Microsoft. TrailsBI is not affiliated with or endorsed by Microsoft.
