Sub topic 7
Republishing updates and handling name conflicts
This chapter assumes you can build a simple report in Power BI Desktop and have already published one to a workspace. You should know that publishing creates a report and a semantic model (the data behind it) in the workspace. Here you will learn what happens when you publish a file whose name already exists, and how to avoid losing work.
How the service matches names
The Power BI service identifies content by name within a workspace. When you publish a .pbix file, it checks whether the workspace already holds a semantic model with that name. The result depends on how you publish.
- From Power BI Desktop: a name match opens a prompt that asks whether to replace the existing items.
- From PowerShell or the REST API: you choose a conflict mode in the command. Nothing prompts you.
The file name on disk does not decide the match. The name of the report and semantic model in the workspace does.
Republishing from Power BI Desktop
Open the updated .pbix file, select Publish on the Home tab, and pick the same workspace. If an item with the same name exists, Desktop shows a Replace option.
- Select Replace to overwrite the existing report and semantic model with your new version.
- Select Cancel to stop and keep what is in the workspace.
Replacing swaps in the new report pages, visuals, data model, and queries. The report keeps its place in the workspace. Links to the report and any apps built on it generally continue to work because the item is updated in place rather than deleted and recreated.
What a replace changes and what it keeps
A replace overwrites the report definition and the model definition. It does not always keep everything you configured in the service.
| Item | After replace |
|---|---|
| Report pages and visuals | Replaced by the new file |
| Data model, measures, queries | Replaced by the new file |
| Scheduled refresh settings | Usually kept |
| Data source credentials | Usually kept if the data source is unchanged |
| Row-level security role members | Kept, but check them after changing roles |
| Edits made in the service | Lost if they conflict with the new file |
If you changed the data source (for example, a new server name), expect to re-enter credentials. Always verify refresh after a replace.
Conflict modes in PowerShell
New-PowerBIReport takes a -ConflictAction parameter. The common values are:
| Value | Behavior |
|---|---|
| `Abort` | Fails if a same-named item exists. This is the default. |
| `CreateOrOverwrite` | Replaces a same-named item, or creates one if none exists. |
| `Overwrite` | Replaces an existing item and fails if none exists. |
| `Ignore` | Creates another item with the same name. |
This example republishes with overwrite:
Connect-PowerBIServiceAccount
$ws = Get-PowerBIWorkspace -Name 'Sales Analytics'
New-PowerBIReport -Path '.\Sales.pbix' -Name 'Sales' -Workspace $ws -ConflictAction CreateOrOverwriteCreateOrOverwrite is convenient for repeatable scripts, because the same command works the first time and every time after.
Conflict modes in the REST API
The Imports operation uses the nameConflict query parameter. Its values include Ignore, Abort, Overwrite, and CreateOrOverwrite.
curl -X POST "https://api.powerbi.com/v1.0/myorg/groups/$GROUP_ID/imports?datasetDisplayName=Sales&nameConflict=CreateOrOverwrite" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-F "[email protected]"The datasetDisplayName value sets the name used for matching. If it differs from the existing name, no conflict occurs and you get a new item.
Common errors
- Duplicate items. Using
Ignore, or changing the display name, creates a second copy. Reports bound to the old semantic model do not move to the new one. - Import fails with a conflict message. The mode is
Abort. Switch to an overwrite mode or rename the item. - Replace is blocked. Your role may not allow it. Contributors can replace only items they are permitted to edit, and Viewers cannot publish at all.
- Refresh fails after replace. The data source or credentials changed. Reopen the semantic model settings and sign in again.
- Overwriting a semantic model used by other reports. Other reports connected to it pick up the new model. Removing a column or measure they rely on breaks their visuals.
Exercise
You run New-PowerBIReport -Path '.\Sales.pbix' -Name 'Sales' -Workspace $ws twice, using the default conflict action. The first run succeeds. What happens on the second run, and which change makes the script safe to rerun?
Show answer
The second run fails, because the default action is Abort and an item named Sales already exists. Adding -ConflictAction CreateOrOverwrite makes the script create the item on the first run and replace it on later runs.
Exercise
A colleague republishes Sales.pbix with nameConflict=Ignore. Afterward the workspace shows two semantic models named Sales. Why did this happen, and what should they have used?
Show answer
Ignore tells the service to create a new item even when the name matches, so a duplicate appears. They should have used Overwrite (or CreateOrOverwrite) to replace the existing item.