Sub topic 12
Managing credentials and privacy levels
This chapter assumes you can open Power BI Desktop, build a basic query in Power Query Editor, and connect to an Excel, CSV, or SharePoint source. It covers two separate settings that people often mix up. Credentials decide who you are when Power BI opens a source. Privacy levels decide whether data from one source may be sent to another source. Both settings are stored per source, and both affect whether a published report can refresh.
Credentials and privacy levels are different settings
A credential is the identity Power BI presents to a data source. A privacy level is a label you give a source, and Power Query uses it to decide how data from different sources can be combined.
| Setting | Question it answers | Where you set it |
|---|---|---|
| Credential | Who is opening this source? | Data source settings, or the prompt on first connection |
| Privacy level | May this source's data be sent to another source? | Data source settings, or the privacy prompt |
| Privacy-level enforcement | Does Power Query apply those labels? | File > Options and settings > Options > Privacy |
Power BI Desktop saves credentials on your computer, not inside the .pbix file. When you publish the report, the service does not receive them. You must enter them again in the service for the dataset (also called a semantic model).
Credential types for file and SharePoint sources
Which credential types you see depends on the connector.
| Source | Typical credential type | Notes |
|---|---|---|
| Local Excel or CSV file | Windows | Uses the Windows account that runs the refresh. A local path such as `C:\Data\Sales.xlsx` is readable only from the machine that has it. |
| Network share (UNC path) | Windows | The account needs read access to the share. |
| SharePoint Online files or lists | Organizational account | Sign in with your Microsoft Entra ID (formerly Azure AD) work account. |
| SharePoint Online, anonymous site | Anonymous | Rare. Use it only for content that is genuinely public. |
For SharePoint Online, sign in with an organizational account. Power BI stores an OAuth token for that account. If the account's password changes, or the token expires or is revoked, refresh fails until you sign in again.
Setting a credential in Power BI Desktop
The first time you run a query against a new source, Desktop asks for a credential. You can also change it later.
- Select Home > Transform data > Data source settings.
- Choose Data sources in current file to see only the sources this report uses, or Global permissions to see every source Desktop remembers.
- Select the source and choose Edit Permissions.
- Under Credentials, select Edit, pick the credential type, and enter the details.
- Set the Privacy Level (covered below) and select OK.
Use Clear Permissions to remove a saved credential. The next refresh will ask you again. This is the quickest fix when a stale credential causes an error, such as a file that "worked yesterday."
SharePoint credentials are saved at the site level. For the examples in this tutorial, one sign-in for https://contoso.sharepoint.com/sites/Sales covers both SharePoint.Files and SharePoint.Tables against that site. When you choose the credential scope in the prompt, a broader scope (the whole site) means fewer prompts. A narrower scope (one folder) gives finer control.
let
Source = SharePoint.Tables("https://contoso.sharepoint.com/sites/Sales", [ApiVersion = 15]),
Tasks = Source{[Title = "Tasks"]}[Items]
in
TasksThe query above holds no password or token. The credential is attached to the site URL in Data source settings, not to the M code.
Why privacy levels exist
Suppose one query reads a local customer list, and another reads a SharePoint list. If you merge them, Power Query may try to speed things up by sending values from the first source to the second as part of a request. If the first source is confidential, those values would leave your machine and reach another system.
Privacy levels prevent that. Each source gets one of three labels.
| Level | Meaning | Data may be sent to other sources? |
|---|---|---|
| Private | Sensitive or confidential data | No |
| Organizational | Visible to a trusted group, such as your company | Only to other Organizational sources |
| Public | Freely available data | Yes, and others may read it |
Use these as a rule of thumb. Payroll or customer data is Private. A shared company workbook on SharePoint is Organizational. A government open-data CSV is Public.
How Power Query applies the levels
The levels matter when a query combines two or more sources, for example with a merge (join) or an append, or when a step takes a value from one source and uses it in another. Power Query groups data into partitions by source and privacy level. It checks whether data from one partition may move to another.
- Private data is never sent to another source. Power Query loads it first and combines it locally.
- Organizational data may go only to other Organizational sources.
- Public data can go anywhere, but Public sources cannot receive Private data.
Combining locally is safe but can be slower, because Power Query cannot ask the source to do part of the work. This is rarely a problem for Excel and CSV files, because they are always read in full and processed in memory.
The Formula.Firewall error
The most common privacy-level error reads like this: "Formula.Firewall: Query 'Orders' (step 'Merged') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination."
It appears when a single step both reads a data source and references another query. Power Query cannot tell which partition owns the step, so it refuses to run it. A typical cause is a query that calls Csv.Document(File.Contents(...)) and, in the same query, merges with a second query.
The most reliable fix is to separate the two jobs.
- Create one query that only loads the source and does the cleaning, such as the CSV import with promoted headers and types.
- Create a second query that references the first and does the merge or append.
- Keep data access and combination in different queries.
let
Source = Csv.Document(File.Contents(FolderPath & "orders.csv"), [Delimiter = ",", Encoding = 65001]),
Promoted = Table.PromoteHeaders(Source, [PromoteAllScalars = true])
in
PromotedThis query only reads and promotes headers. Save it as Orders. Then build the merge in a separate query that refers to Orders. The query uses the FolderPath parameter from the earlier chapter, so the path is not hard-coded.
Privacy-level enforcement options
Under File > Options and settings > Options > Privacy, you choose how Desktop treats privacy levels for the current file and for new files.
- Always combine data according to your Privacy Level settings for each source applies the labels strictly. This is the safe choice.
- Combine data according to each file's Privacy Level settings uses whatever each .pbix file stores.
- Ignore the Privacy Levels and potentially improve performance turns the checks off. Desktop will not raise Formula.Firewall errors, and it will also not stop data moving between sources.
Ignoring privacy levels is a trade-off, not a fix. It removes the protection those levels give, and the choice applies to Desktop only. In the Power BI service, the dataset owner can set the same behavior in the dataset's data source credentials, but your organization may restrict that. If you turn the checks off to get past an error, record the reason and limit it to sources you are sure are safe to mix.
Credentials after publishing
After you publish, open the semantic model's settings in the Power BI service and expand Data source credentials. Each source in the model appears there.
- A SharePoint Online source normally shows OAuth2 as the authentication method. Select Edit credentials, sign in, and set the privacy level.
- A local file shows an error that the source cannot be reached from the cloud, because the service cannot read
C:\Data. That source needs an on-premises data gateway, which is the subject of the next chapter.
The privacy level you set in the service is stored with the dataset, separate from the level in Desktop. If you set Private in Desktop and leave the service value as Organizational, the service uses what you set there. Check both places.
For scheduled refresh, the account that signed in is the one the service uses. If that person leaves the company or their sign-in expires, refresh starts failing. For shared reports, use a dedicated account with read access to the site, or a data source that does not depend on one person's identity, and document who owns the credential.
Common mistakes
- Setting every source to Public to silence prompts. This disables the protection and can send confidential values to other sources.
- Assuming credentials travel with the .pbix file. They do not, so a new colleague or the service must sign in again.
- Mixing data access and merging in one query, which causes Formula.Firewall.
- Using a personal account for a shared, scheduled report.
- Forgetting that changing the site URL (for example, through a parameter) creates a new data source that needs its own credential and privacy level.
Exercise
A query reads a local CSV of salary data and a SharePoint list of department names, then merges them. Which privacy levels would you assign, and what is the safest way to avoid a Formula.Firewall error?
Show answer
Set the salary CSV to Private and the SharePoint list to Organizational. Private data is never sent to another source, so Power Query combines the two locally. To avoid Formula.Firewall, put each source in its own query that only loads and cleans data, then do the merge in a third query that references them. Do not set the CSV to Public.
Exercise
You change a query parameter to point at a different SharePoint site URL, and the next refresh prompts for sign-in. Why?
Show answer
Credentials and privacy levels are stored per data source, identified by its URL. A different site URL is a new data source with no saved credential or privacy level, so Power BI asks for both again.