> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jaantonio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Power BI

> Connect Power BI to Analytics Postgres and build a durable reporting model.

Power BI uses the same Postgres credentials as any other client. Most organizations should have one person set up the model once, publish it, and let everyone else consume reports.

Lambda gives you the database and the `reporting` contract. It does not ship a finished `.pbix` file into your tenant.

## Before you start

1. Create a credential in Lambda under **Settings → Analytics**. See [Connect](/analytics/connect).
2. Decide who owns the Power BI workspace and the cloud connection. Prefer a shared service identity, not one employee's personal account.
3. Keep at least two workspace admins.

## Connect Desktop to Postgres

<Steps>
  <Step title="Get data">
    Use the **PostgreSQL** connector. Enter the host and database from Lambda.
  </Step>

  <Step title="Sign in">Use the username and password. Require encryption.</Step>

  <Step title="Load reporting views">
    Navigate to schema `reporting` and select the views you need. For a first model, start with
    `shipments`, `shipment_versions`, and `shipment_changes`.
  </Step>
</Steps>

Add discovery views only when someone needs field hunting or detail drills.

## Storage modes

| Query                         | Suggested mode                                                |
| ----------------------------- | ------------------------------------------------------------- |
| Shipments                     | DirectQuery                                                   |
| Shipment versions and changes | DirectQuery                                                   |
| Deliveries and messages       | DirectQuery                                                   |
| Payload metadata              | Dual or Import                                                |
| Discovery fields catalog      | Dual or Import                                                |
| Discovery observations        | DirectQuery with date and path filters, or incremental Import |

<Tip>
  Observations are the heavy table. Always fold a date window (and usually a path or label filter)
  before you put them on a page.
</Tip>

## Relationships

Turn off automatic relationship detection and automatic date tables. Create explicit single-direction relationships:

* `shipments[shipment_key]` → `shipment_versions[shipment_key]`
* `shipments[shipment_key]` → `shipment_changes[shipment_key]`
* `cargowise_payloads[payload_id]` → `cargowise_deliveries[payload_id]`
* `cargowise_deliveries[event_id]` → `cargowise_messages[event_id]`
* `cargowise_payloads[payload_id]` → observations on `payload_id`
* `cargowise_xml_fields[semantic_field_key]` → observations on `semantic_field_key`

<Warning>
  Do not relate deliveries directly to observations. One payload can have many deliveries; join
  observations through `payload_id`.
</Warning>

Use `job_number` for business filters and labels. Keep `shipment_key` for joins.

## Publish and keep it live

<Steps>
  <Step title="Publish">Publish the model to a Power BI workspace.</Step>

  <Step title="Configure the cloud connection">
    Use the same Postgres login. Cap the data source maximum connections at **5** so it matches the
    database limit.
  </Step>

  <Step title="Share reports, not passwords">
    Give consumers Viewer access. Do not hand the Postgres password to every report reader.
  </Step>
</Steps>

The connection stays usable until the credential is rotated or revoked. New data appears through DirectQuery or on the next Import refresh. You do not rebuild the model just because the dataset updated.

When you rotate a password in Lambda, update the stored credential in the Power BI connection once.

## What "build the model once" means

1. Connect with the credential
2. Load the curated views
3. Set relationships and refresh behavior
4. Publish

After that, day-to-day work is opening reports — not redoing connection setup.

## Prefer a database client instead?

That is supported. Use the same host, port, user, and password in any Postgres client and query `reporting` directly. Power BI is optional.
