Sub topic 7
Republishing updates and handling name conflicts
This chapter assumes you have already published a report once from Power BI Desktop. It also assumes you know the difference between the report and the semantic model that publishing creates, and that you can open a workspace and see its contents. Here you will learn what happens when you publish the same .pbix file again, how Power BI decides that two items "conflict," and how to control the outcome from Desktop, PowerShell, and the REST API.
How Power BI decides that a name conflicts
Power BI matches items by display name inside one workspace. It does not match by file path, by an internal ID stored in the .pbix, or by who published the file. When you publish, the service compares two names with what is already in the target workspace:
- The name of the report, which Desktop takes from the .pbix file name without the extension.
- The name of the semantic model, which uses the same name.
Two consequences follow from this rule:
- The same name in a different workspace is never a conflict.
Salesin "Sales Analytics" andSalesin "Finance Sandbox" are independent items. - Renaming the file changes the match. If you save
Sales.pbixasSales v2.pbixand publish it, the service sees a new name, creates a second report and a second semantic model, and leaves the old ones in place.
The second point is the most common source of duplicate reports. If you want to update an existing report, keep the file name stable.
What happens when you publish again from Desktop
When you choose Publish and pick a workspace that already contains a semantic model with the same name, Desktop shows a prompt. It tells you that a semantic model with that name exists and offers Replace or Cancel. Choosing Replace overwrites the existing items.
What gets replaced:
- The semantic model. The model definition (tables, relationships, measures, and so on) and the data stored in the file replace what the service holds.
- The report. The report pages and visuals in the workspace are replaced by the ones in your file.
What is usually kept:
- The item identity. The report and semantic model keep their place in the workspace, so existing links to the report keep working.
- Dashboard tiles. Tiles pinned from the report continue to point at it. A tile can break if you delete or rename the visual it was pinned from.
- Access settings. Workspace roles and any app or direct-share permissions stay as they were.
- Refresh settings. The schedule and stored credentials normally survive an overwrite, as long as the data sources are unchanged.
What you can lose:
- Edits made in the service. If someone changed the report in the browser, for example by adding a page or changing a visual, republishing overwrites those edits with what is in your .pbix. The file is treated as the source of truth.
- Data freshness. The overwritten semantic model holds the data from your last refresh in Desktop. If the service refreshed more recently than you did, the published data goes backward until the next scheduled refresh.
Changes that need a second look after republishing
Overwriting does not always leave everything as you expect. Check the following after any republish that changes the data side:
- Changed data sources. If you point a query at a different server, database, or URL, the old stored credentials do not apply to the new source. Open the semantic model settings and set credentials again. The next chapter covers credentials and gateways in more detail.
- Changed parameters. Power Query parameters are part of the model. After a republish, open the semantic model settings and confirm that the parameter values are what you intend.
- A failed or paused schedule. A refresh that was failing before the republish keeps failing if the cause was the data source. Republishing does not fix refresh problems.
- Report-only (thin) files. A report connected live to an existing semantic model in the service has no model of its own. Publishing it creates or overwrites only the report, and the shared semantic model is left alone.
The decision flow
The following diagram shows how a publish request is resolved against the target workspace.
Conflict behavior in scripts
Desktop asks you a question. A script has to answer it in advance, so both automation routes take a conflict setting. The setting is easy to get wrong, because the default does not do what most people expect from an update.
PowerShell: `-ConflictAction`
The New-PowerBIReport cmdlet in the MicrosoftPowerBIMgmt module accepts these values:
| Value | Behavior when the name already exists | Behavior when it does not exist |
|---|---|---|
| `Ignore` | Default. Does not reliably update the existing items. Avoid it for .pbix uploads. | Creates the items |
| `Abort` | Stops with an error and changes nothing | Creates the items |
| `Overwrite` | Replaces the existing items | Fails, because there is nothing to replace |
| `CreateOrOverwrite` | Replaces the existing items | Creates the items |
CreateOrOverwrite is the best fit for a repeatable pipeline, because the same command works on the first run and on every later run. Abort is the safest choice when a human should decide, for example in a manual release step. Overwrite is useful when you want a run to fail loudly if the target has been deleted or renamed.
Before overwriting, you can see what is already there:
Connect-PowerBIServiceAccount
$ws = Get-PowerBIWorkspace -Name 'Sales Analytics'
# What exists under this name right now?
Get-PowerBIReport -Workspace $ws -Name 'Sales'
Get-PowerBIDataset -Workspace $ws -Name 'Sales'If both commands return an item, an overwrite will replace it. If they return nothing, CreateOrOverwrite will create new items.
To publish without ever replacing anything, use Abort:
Connect-PowerBIServiceAccount
$ws = Get-PowerBIWorkspace -Name 'Sales Analytics'
New-PowerBIReport -Path '.\Sales.pbix' -Name 'Sales' -Workspace $ws -ConflictAction AbortOn a second run this command errors out because Sales already exists, and the workspace is not modified.
REST API: `nameConflict`
The Imports operation takes the name conflict as a query parameter. The semantic model name comes from datasetDisplayName, and that name is what the service compares against existing items.
| Value | Effect on a .pbix import |
|---|---|
| `Abort` | Fails if an item with that name exists |
| `Overwrite` | Replaces the existing items, and fails if none exist |
| `CreateOrOverwrite` | Replaces the existing items, or creates them if none exist |
| `GenerateUniqueName` | Creates new items with a generated unique name instead of replacing |
The API also has an Ignore value, and it is the default when you leave the parameter out. Set nameConflict explicitly for every .pbix upload so the behavior is written down in your script.
curl -X POST "https://api.powerbi.com/v1.0/myorg/groups/$GROUP_ID/imports?datasetDisplayName=Sales&nameConflict=Abort" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-F "[email protected]"A successful request returns an import ID. The upload is processed asynchronously, so a response that accepts the request does not yet mean the new version is live. To confirm the outcome, poll the import by its ID with GET .../groups/$GROUP_ID/imports/{importId}. The importState field moves to Succeeded or Failed. In a pipeline, wait for that state before running later steps such as triggering a refresh.
Choosing a strategy
Match the behavior to how your team works:
- One author, Desktop is the source of truth. Use Replace in Desktop, or
CreateOrOverwritein a script. Tell the team not to edit the report in the browser. - Several people edit in the service. Overwriting will discard their work. Either move all edits into the .pbix, or publish to a separate review workspace first and copy changes across by hand.
- You want a safety net. Use
Abortin the script and delete or rename the old item deliberately when you want it replaced. UseGenerateUniqueNamewhen you want a side-by-side copy to compare, then delete the loser. - Several reports share one model. Publish the model once from a single .pbix, and build the other reports as thin reports on top of it. Overwriting the model then updates every report that uses it.
Common mistakes
- Duplicates after renaming the file. The names no longer match. Delete the old items or rename the file back.
- Report replaced but the semantic model name differs. If you published the report under a custom name with a script, the report name and
datasetDisplayNamecan drift apart. Pass both consistently, or let the cmdlet use the same value for both. - Assuming
Ignoremeans "update." It does not. UseCreateOrOverwrite. - Treating the 202 or "accepted" response as success. Check the import state before depending on the new version.
- Forgetting that the data comes from the file. If your local data is a week old, the service now holds week-old data until a refresh runs. Refresh in Desktop before publishing, or trigger a service refresh afterward.
- Overwriting while a refresh is running. The refresh can fail or its result can be discarded. Publish outside your scheduled refresh window.
Exercises
Exercise
You published Sales.pbix to the workspace "Sales Analytics". A colleague then saved a copy as Sales Q4.pbix, changed one page, and published it to the same workspace. What does the workspace contain, and why?
Show answer
It contains two reports and two semantic models: Sales and Sales Q4. Power BI matches by display name within a workspace, and Desktop takes the name from the file name. Sales Q4 does not match Sales, so nothing is overwritten and new items are created.
Exercise
A nightly script uploads Sales.pbix to the same workspace on every run. Which -ConflictAction value should you use so that the first run creates the report and later runs replace it, and why not Overwrite?
Show answer
Use CreateOrOverwrite. It creates the items when they do not exist and replaces them when they do. Overwrite fails on the first run, or after someone deletes the report, because it needs an existing item to replace.
Exercise
After republishing with Replace, a user reports that the report shows last week's numbers, although the service refreshed successfully yesterday. What is the likely cause and the fix?
Show answer
The overwrite replaced the semantic model with the data stored in the .pbix, which was last refreshed in Desktop a week ago. The fix is to trigger a refresh in the service, or wait for the next scheduled one. To avoid it, refresh in Desktop before publishing.