---
title: "Test a Power BI Desktop file"
description: "Test the model in a .pbix or .pbip file open in Power BI Desktop — the file name is the connection; no driver, no service principal"
url: "https://docs.justcat.it/how-to-guides/data-platforms/power-bi/test-a-power-bi-desktop-file/"
---
# Test a Power BI Desktop file


## Prerequisites

Power BI Desktop on the machine where CAT runs, with the file open while the tests run. Windows only (Power BI Desktop is). No driver, no account, no permissions — the open file is reachable on the machine.

## Add the data source


**CAT Studio**


**Data sources → New data source**: a name, technology *Power BI Desktop*, and the name of the open file as Power BI Desktop shows it in its window title — `Finance` for `Finance.pbix`. Save. The test editor on the **Tests** page now runs DAX against the file.


**YAML**


```yaml
Data sources:
- Name: finance model
  Provider: PowerBI@2
  Connection string: Finance   # the open file's name, without .pbix / .pbip
```

CAT finds the Analysis Services instance Power BI Desktop runs under the hood by itself. See [PowerBI@2](https://docs.justcat.it/reference/data-sources/providers/powerbi-2/ "PowerBI@2").




## Write the first test

A smoke test — the table has rows:


**Properties**



Name
: Account table is loaded

Suite
: Smoke tests

Data source
: finance model

Query
: EVALUATE 'Account'

Expectation
: set is not empty





**YAML**


```yaml
Tests:
- Name: Account table is loaded
  Suite: Smoke tests
  Data source: finance model
  Query: EVALUATE 'Account'
  Expectation: set is not empty
```




And the one that pays off — the model agrees with the source it was built from. Both queries return one column, both ordered; the data sources may be different technologies:


**Properties**


**Data sources**


Name
: finance model

Provider
: PowerBI@2

Connection string
: Finance





Name
: accounting

Provider
: SqlServer@2

Connection string
: %ACCOUNTING_CONNECTION_STRING%




**Tests**


Name
: All states are in the model

Suite
: Model vs source

First data source
: finance model

First query
: ```
  EVALUATE VALUES('Customer'[State])
  ORDER BY 'Customer'[State]
  ```

Second data source
: accounting

Second query
: SELECT StateName FROM dbo.States ORDER BY StateName

Expectation
: sets match





**YAML**


```yaml
Data sources:
- Name: finance model
  Provider: PowerBI@2
  Connection string: Finance
- Name: accounting
  Provider: SqlServer@2
  Connection string: "%ACCOUNTING_CONNECTION_STRING%"

Tests:
- Name: All states are in the model
  Suite: Model vs source
  First data source: finance model
  First query: |
    EVALUATE VALUES('Customer'[State])
    ORDER BY 'Customer'[State]
  Second data source: accounting
  Second query: SELECT StateName FROM dbo.States ORDER BY StateName
  Expectation: sets match
```




Where the DAX comes from when you do not want to write it: [Get the DAX query behind a visual](https://docs.justcat.it/how-to-guides/data-platforms/power-bi/get-the-dax-query-behind-a-visual/ "Get the DAX query behind a visual"). More tests worth having — totals, measures per year with a tolerance, blank checks — on [Test measures](https://docs.justcat.it/how-to-guides/data-platforms/power-bi/test-measures/ "Test measures").

## Good to know

* The file must stay **open** while the tests run; close it and the next run ends with `Error` on every test of that data source.
* Two files open at once are two data sources — each by its own name.
* The same project file tests the published model later: swap the data source for a [Dax@2](https://docs.justcat.it/reference/data-sources/providers/dax-2/ "Dax@2") one, keep every test. See [Test a semantic model in a workspace](https://docs.justcat.it/how-to-guides/data-platforms/power-bi/test-a-semantic-model-in-a-workspace/ "Test a semantic model in a workspace").

## Related

* [Test Power BI](https://docs.justcat.it/how-to-guides/data-platforms/power-bi/test-power-bi/ "Test Power BI") — the overview.
* [PowerBI@2](https://docs.justcat.it/reference/data-sources/providers/powerbi-2/ "PowerBI@2") — the provider, with its limitations.

