Sub topic 12
Inspecting and refreshing partitions through the XMLA endpoint
Earlier chapters showed that the service turns your refresh policy into partitions. This chapter covers the XMLA endpoint, which lets you see those partitions and refresh some of them without waiting for the next scheduled run. It is an optional topic. You can run incremental refresh for years without it, but it is the main tool for diagnosing and recovering a dataset.
Prerequisites
This chapter assumes you have:
- a dataset published with a working refresh policy and at least one successful refresh
- a basic idea of what a partition is: a slice of a table that can be refreshed on its own
- a workspace on Premium capacity, Premium Per User, or Fabric capacity
- some comfort with JSON and with a tool such as SQL Server Management Studio (SSMS)
What the XMLA endpoint is
The XMLA endpoint is a connection address for a workspace. It exposes each dataset in that workspace as an Analysis Services database. Any client that speaks XMLA can connect to it, read the model's metadata, and send commands to it.
The endpoint is closed to non-Premium workspaces. A capacity admin must also set the XMLA endpoint to Read Write in the capacity settings. In Read Only mode you can query and inspect, but you cannot refresh.
The address has this form:
powerbi://api.powerbi.com/v1.0/myorg/Sales WorkspaceReplace Sales Workspace with your workspace name. In a client such as SSMS, choose the server type Analysis Services, paste the address as the server name, and sign in with your organizational account. Each dataset in the workspace then appears as a database.
Common clients are:
| Tool | Typical use |
|---|---|
| SSMS | Browse partitions, run TMSL scripts, process tables |
| Tabular Editor | Edit model metadata, view partition properties |
| DAX Studio | Run DMV queries and inspect storage |
| ALM Toolkit | Compare and deploy model changes while keeping partitions |
| PowerShell (`SqlServer` module) | Script refreshes from a scheduler or pipeline |
Reading the partitions the policy created
Once the first refresh finishes, a table with a policy contains one partition per period. The partition names follow the granularity you chose:
| Granularity | Example partition name |
|---|---|
| Year | `2024` |
| Quarter | `2024Q1` |
| Month | `202401` |
| Day | `20240115` |
The names are generated by the service. You do not choose them, and you should not rename them.
In SSMS, expand the dataset, then Tables, then right-click FactSales and choose Partitions. The dialog lists every partition with its name, last processed time, and size. A partition that was never loaded has an empty processed time.
You can get the same information with a query. Open an MDX/DMV query window against the dataset and run:
SELECT [ID], [TableID], [Name], [State], [Mode], [RefreshedTime]
FROM $SYSTEM.TMSCHEMA_PARTITIONSEach row is one partition. The useful columns are:
Name: the generated period name.State: whether the partition holds data. A value ofReadymeans it is loaded.Mode: the storage mode. Import partitions and the DirectQuery partition of a hybrid table show different values here.RefreshedTime: when the partition was last loaded.
The query returns partitions for all tables. To limit it to one table, look up that table's ID in $SYSTEM.TMSCHEMA_TABLES and filter on TableID.
This view answers the questions that the Desktop dialog cannot:
- Did the service create the number of partitions you expected from the policy?
- Is every archive partition loaded, or did some fail?
- Did the scheduled refresh touch only the incremental partitions? If archive partitions show a recent
RefreshedTime, the policy is not working as intended. - Is there a partition for today? If the newest partition is old, the policy window has not rolled forward.
Refreshing a single partition
The most common reason to use XMLA is to reload one partition. For example, a late correction landed in March of last year, which sits in the archive period and so is never touched by the scheduled refresh. A full dataset refresh would reload everything. A partition refresh reloads only the month that changed.
Commands for Analysis Services models are written in TMSL (Tabular Model Scripting Language), which is JSON. Open an XMLA query window in SSMS, connect to the dataset, and run:
{
"refresh": {
"type": "full",
"applyRefreshPolicy": false,
"objects": [
{
"database": "SalesModel",
"table": "FactSales",
"partition": "202403"
}
]
}
}The pieces work like this:
type: "full"clears the partition and reloads it from the source.objectsnames the database, table, and partition to process. Add more objects to refresh several partitions in one command.applyRefreshPolicy: falsetells the service to refresh exactly what you listed. Without it, the refresh also applies the policy, which can create, drop, or merge partitions as the date rolls forward. During a targeted repair you usually want only the reload.
The partition query that runs at the source still carries the RangeStart and RangeEnd filter for that period. If query folding works, the source receives a WHERE clause covering only March 2024.
You can run the same command from a script. The SqlServer PowerShell module provides Invoke-ASCmd, which sends a TMSL script to the endpoint:
$tmsl = @'
{
"refresh": {
"type": "full",
"applyRefreshPolicy": false,
"objects": [
{ "database": "SalesModel", "table": "FactSales", "partition": "202403" }
]
}
}
'@
Invoke-ASCmd `
-Server "powerbi://api.powerbi.com/v1.0/myorg/Sales Workspace" `
-Query $tmslWithout extra parameters, this prompts for an interactive sign-in. For unattended runs, use a service principal. The service principal must be allowed to use the XMLA endpoint and must have at least the Member role in the workspace.
Refresh types you will use
The type value controls how much work a partition does.
| Type | What it does | When to use it |
|---|---|---|
| `full` | Clears the partition and reloads it | Correcting data in a closed period |
| `clearValues` | Empties the partition without reloading | Freeing memory, or preparing a clean reload |
| `calculate` | Recalculates calculated columns and tables, relationships, and hierarchies without loading data | After a metadata change, once partitions are loaded |
| `dataOnly` | Loads data without recalculating | Loading many partitions, then running one `calculate` at the end |
The dataOnly plus calculate pattern matters when you load many partitions. Each full refresh recalculates dependent objects. Loading all partitions with dataOnly and then running a single calculate avoids repeating that work for every partition.
Spreading out a very large first load
The first refresh after publishing loads every partition in the policy. For a table with years of history, this can exceed refresh time limits and fail. The partitions that finished are kept only if the refresh commits them, so a timeout can mean starting over.
XMLA gives you a way out. Once the partitions exist, you can refresh them in separate commands, such as one year per command, so that no single operation is too long. Microsoft's documentation on advanced incremental refresh describes the supported way to create the partitions without loading all the data first. Check it for your capacity type, because the exact steps depend on the settings that are available to you.
Whichever approach you use, finish by confirming with the DMV query that every partition is Ready.
Gotchas
A pbix file can no longer be downloaded. After you change a dataset through the XMLA endpoint, you cannot download it as a .pbix file from the service. A dataset with incremental refresh already has this restriction. Keep your Desktop file or a source-controlled model as the source of truth.
Republishing replaces partitions. If you publish the same .pbix over the dataset, the service replaces the data, and the next refresh rebuilds all partitions. To deploy a metadata change without losing loaded partitions, use a tool that deploys metadata only, such as ALM Toolkit or Tabular Editor, and skip the partition objects in the comparison.
Read Only mode blocks the commands. A refresh sent to an endpoint that is set to Read Only fails with a permissions-style error. Check the capacity setting before debugging the script.
Capacity matters. Partition refreshes use the same memory and parallelism as other refreshes on the capacity. Refreshing many large partitions in parallel can hit memory limits. When this happens, split the command into batches.
Policy-driven changes are not hand-managed. Use XMLA to read partitions and to reload specific ones. Do not use it to redesign partitions. If you need a different window or granularity, change the policy in Desktop or in the model metadata, and let the service rebuild the partitions.
When to reach for XMLA
Use it when:
- a closed period needs to be reloaded because the source was corrected
- you need to confirm which partitions exist and when they last refreshed
- a refresh keeps failing and you need to find the failing partition
- the first load is too large for one refresh
Skip it when a scheduled refresh and the Desktop settings already do what you need. Most datasets never require the endpoint.
Exercise
A data fix changed rows dated February 2023 in a table with a policy that keeps five years and refreshes the last 10 days. The scheduled refresh did not pick up the change. Which command would you send to correct it, and why would you set applyRefreshPolicy to false?
Show answer
February 2023 lies in the archive period, which scheduled refreshes do not touch. Send a TMSL refresh with type "full" naming the database, the table, and the February 2023 partition (named 202302 if the archive granularity is month). Set applyRefreshPolicy to false so the service reloads only that partition and does not also create, drop, or merge partitions as part of the policy.
Exercise
You run the TMSCHEMA_PARTITIONS query the morning after a scheduled refresh and see recent RefreshedTime values on every archive partition. What does this suggest, and where would you look first?
Show answer
The refresh is reloading the whole table, so the incremental setup is not working. Look first at query folding of the RangeStart and RangeEnd filter, and then at whether another process, such as a manual full refresh or a republish, reloaded the partitions.