{"id":1594,"date":"2026-05-02T17:18:27","date_gmt":"2026-05-02T15:18:27","guid":{"rendered":"https:\/\/www.flip-design.de\/?p=1594"},"modified":"2026-05-02T17:18:27","modified_gmt":"2026-05-02T15:18:27","slug":"creation-and-processing-of-power-bi-ssas-partitions-using-sql-server-management-studio-and-powershell","status":"publish","type":"post","link":"https:\/\/www.flip-design.de\/?p=1594","title":{"rendered":"Creation and processing of Power BI\/SSAS partitions using SQL Server Management Studio and PowerShell"},"content":{"rendered":"\n<p>This entire functionality only works with Fabric or Premium. The workspace must be configured accordingly. In the underlying SSAS cube (semantic model), the data is stored in corresponding partitions. The purpose here is not to improve performance, as known from the multidimensional model, but rather to increase the speed of data transfer and data loading.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image.png\"><img decoding=\"async\" loading=\"lazy\" width=\"940\" height=\"459\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image.png\" alt=\"\" class=\"wp-image-1595\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image.png 940w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-300x146.png 300w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-768x375.png 768w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/a><\/figure>\n\n\n\n<p>You can then copy the XMLA endpoint from the properties of the semantic model. This requires that the read\/write option has been enabled in the admin portal.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-1.png\"><img decoding=\"async\" loading=\"lazy\" width=\"940\" height=\"459\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-1.png\" alt=\"\" class=\"wp-image-1596\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-1.png 940w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-1-300x146.png 300w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-1-768x375.png 768w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/a><\/figure>\n\n\n\n<p>You can now connect to the semantic model in Management Studio using this address.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-2.png\"><img decoding=\"async\" loading=\"lazy\" width=\"745\" height=\"800\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-2.png\" alt=\"\" class=\"wp-image-1597\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-2.png 745w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-2-279x300.png 279w\" sizes=\"(max-width: 745px) 100vw, 745px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-3.png\"><img decoding=\"async\" loading=\"lazy\" width=\"516\" height=\"547\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-3.png\" alt=\"\" class=\"wp-image-1598\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-3.png 516w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-3-283x300.png 283w\" sizes=\"(max-width: 516px) 100vw, 516px\" \/><\/a><\/figure>\n\n\n\n<p>To view or create partitions, you can access this through the properties of the respective table. In this example, I have only one table in my model.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-4.png\"><img decoding=\"async\" loading=\"lazy\" width=\"509\" height=\"681\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-4.png\" alt=\"\" class=\"wp-image-1599\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-4.png 509w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-4-224x300.png 224w\" sizes=\"(max-width: 509px) 100vw, 509px\" \/><\/a><\/figure>\n\n\n\n<p>The code used here is simply M code, which can be copied from the Advanced Editor in Power Query. To illustrate this a bit further, an additional line is included that renames a column\u2014nothing more. Otherwise, the code filters the data for a full year in order to create the partition.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-5.png\"><img decoding=\"async\" loading=\"lazy\" width=\"940\" height=\"876\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-5.png\" alt=\"\" class=\"wp-image-1600\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-5.png 940w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-5-300x280.png 300w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-5-768x716.png 768w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/a><\/figure>\n\n\n\n<p>This allows you to create a partition, for example for a specific calendar year. The existing default partition can then be removed. After that, the partitions must be processed; the <em>Full<\/em> processing option is recommended, as it removes any existing rows beforehand and reloads them. In general, it is important to ensure that query folding is applied when using compatible data sources, so that in this example only the data for the respective calendar year is selected and transferred.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-6.png\"><img decoding=\"async\" loading=\"lazy\" width=\"940\" height=\"876\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-6.png\" alt=\"\" class=\"wp-image-1602\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-6.png 940w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-6-300x280.png 300w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-6-768x716.png 768w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/a><\/figure>\n\n\n\n<p>You can then view in the properties how many rows are contained in each partition.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-7.png\"><img decoding=\"async\" loading=\"lazy\" width=\"940\" height=\"876\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-7.png\" alt=\"\" class=\"wp-image-1603\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-7.png 940w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-7-300x280.png 300w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-7-768x716.png 768w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/a><\/figure>\n\n\n\n<p>Once a partition has been processed, a corresponding success message can be viewed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-8.png\"><img decoding=\"async\" loading=\"lazy\" width=\"772\" height=\"833\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-8.png\" alt=\"\" class=\"wp-image-1604\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-8.png 772w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-8-278x300.png 278w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-8-768x829.png 768w\" sizes=\"(max-width: 772px) 100vw, 772px\" \/><\/a><\/figure>\n\n\n\n<p>In this example, I also inserted incorrect data for the year 2027 into the database and created a corresponding partition for it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-9.png\"><img decoding=\"async\" loading=\"lazy\" width=\"940\" height=\"876\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-9.png\" alt=\"\" class=\"wp-image-1605\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-9.png 940w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-9-300x280.png 300w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-9-768x716.png 768w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/a><\/figure>\n\n\n\n<p>To correct this error, I remove the partition using the following script. Alternatively, the corresponding button can also be used. However, if this process is to be automated, it is advisable to become familiar with JSON.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\r\n  \"delete\": {\r\n    \"object\": {\r\n      \"database\": \"report\",\r\n      \"table\": \"Query1\",\r\n      \"partition\": \"2027\"\r\n    }\r\n  }\r\n}<\/code><\/pre>\n\n\n\n<p>The data remains available in the source, of course. Therefore, an appropriate data management strategy should be considered.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-10.png\"><img decoding=\"async\" loading=\"lazy\" width=\"940\" height=\"250\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-10.png\" alt=\"\" class=\"wp-image-1606\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-10.png 940w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-10-300x80.png 300w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-10-768x204.png 768w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/a><\/figure>\n\n\n\n<p>I have now inserted additional data into the 2026 partition using the following query. This adds 300 more rows.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>WITH RandomData AS (\r\n    SELECT TOP 300\r\n        ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS rn,\r\n        DATEADD(DAY, ABS(CHECKSUM(NEWID())) % 365, '2026-01-01') AS datum,\r\n        ABS(CHECKSUM(NEWID())) % 200 + 50 AS wert\r\n    FROM sys.objects a\r\n    CROSS JOIN sys.objects b\r\n),\r\nMaxID AS (\r\n    SELECT ISNULL(MAX(id), 0) AS max_id FROM &#91;dbo].&#91;Query1]\r\n)\r\nINSERT INTO &#91;dbo].&#91;Query1] (id, datum, wert)\r\nSELECT \r\n    m.max_id + r.rn AS id,\r\n    r.datum,\r\n    r.wert\r\nFROM RandomData r\r\nCROSS JOIN MaxID m;\r\n<\/code><\/pre>\n\n\n\n<p>To transfer these rows into the partition and automate this process, I use a PowerShell 7 script. Of course, this can also be implemented with PowerShell 5. However, to make the solution future-proof and compatible with Linux, I personally use PowerShell 7 exclusively.<br>The corresponding code can be found here:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># ============================================\r\n# Power BI XMLA Partition Processing\r\n# PowerShell 7 only\r\n# Uses Power BI access token\r\n# ============================================\r\n\r\n$ErrorActionPreference = \"Stop\"\r\n\r\nfunction Step($Text) {\r\n    Write-Host \"\"\r\n    Write-Host \"=== $Text ===\" -ForegroundColor Cyan\r\n}\r\n\r\n# --------------------------------------------\r\n# Configuration\r\n# --------------------------------------------\r\n\r\n$WorkspaceName = \"Partitionierung\"\r\n$DatabaseName  = \"report\"\r\n$TableName     = \"Query1\"\r\n$PartitionName = \"2026\"\r\n\r\n$ServerName = \"powerbi:\/\/api.powerbi.com\/v1.0\/myorg\/$WorkspaceName\"\r\n\r\n# --------------------------------------------\r\n# Load modules\r\n# --------------------------------------------\r\n\r\nStep \"Loading Power BI module\"\r\nImport-Module MicrosoftPowerBIMgmt.Profile\r\n\r\n# --------------------------------------------\r\n# Login to Power BI\r\n# --------------------------------------------\r\n\r\nStep \"Login to Power BI\"\r\n#Connect-PowerBIServiceAccount\r\n\r\n# --------------------------------------------\r\n# Get Power BI access token\r\n# --------------------------------------------\r\n\r\nStep \"Getting Power BI access token\"\r\n\r\n$TokenResponse = Get-PowerBIAccessToken\r\n$AccessTokenString = $TokenResponse.Authorization -replace \"^Bearer\\s+\", \"\"\r\n\r\n# --------------------------------------------\r\n# Load Analysis Services client DLLs\r\n# --------------------------------------------\r\n\r\nStep \"Loading Analysis Services DLLs\"\r\n\r\n$PackageIdLower = \"microsoft.analysisservices.netcore.retail.amd64\"\r\n$PackageRoot    = Join-Path $PSScriptRoot \"packages\"\r\n$ExtractPath    = Join-Path $PackageRoot $PackageIdLower\r\n\r\nif (-not (Test-Path $ExtractPath)) {\r\n    New-Item -ItemType Directory -Path $PackageRoot -Force | Out-Null\r\n\r\n    $IndexUrl = \"https:\/\/api.nuget.org\/v3-flatcontainer\/$PackageIdLower\/index.json\"\r\n    $Versions = Invoke-RestMethod -Uri $IndexUrl\r\n    $LatestVersion = $Versions.versions&#91;-1]\r\n\r\n    $NupkgUrl  = \"https:\/\/api.nuget.org\/v3-flatcontainer\/$PackageIdLower\/$LatestVersion\/$PackageIdLower.$LatestVersion.nupkg\"\r\n    $NupkgFile = Join-Path $PackageRoot \"$PackageIdLower.$LatestVersion.nupkg\"\r\n    $ZipFile   = Join-Path $PackageRoot \"$PackageIdLower.$LatestVersion.zip\"\r\n\r\n    Invoke-WebRequest -Uri $NupkgUrl -OutFile $NupkgFile\r\n    Copy-Item $NupkgFile $ZipFile -Force\r\n    Expand-Archive -Path $ZipFile -DestinationPath $ExtractPath -Force\r\n}\r\n\r\nGet-ChildItem -Path $ExtractPath -Recurse -Filter \"*.dll\" |\r\n    Where-Object { $_.FullName -notmatch \"\\\\(de|fr|es|it|ja|ko|ru|zh|pt|pl|tr)\\\\\" } |\r\n    ForEach-Object {\r\n        try {\r\n            Add-Type -Path $_.FullName\r\n        }\r\n        catch {}\r\n    }\r\n\r\n# --------------------------------------------\r\n# Create Analysis Services access token object\r\n# --------------------------------------------\r\n\r\nStep \"Creating Analysis Services access token object\"\r\n\r\n$ExpirationTime = &#91;DateTimeOffset](Get-Date).AddHours(1)\r\n\r\n$AmoAccessToken = &#91;Microsoft.AnalysisServices.AccessToken]::new(\r\n    $AccessTokenString,\r\n    $ExpirationTime,\r\n    $null\r\n)\r\n\r\n# --------------------------------------------\r\n# TMSL command\r\n# --------------------------------------------\r\n\r\nStep \"Building TMSL\"\r\n\r\n$Tmsl = @\"\r\n{\r\n  \"refresh\": {\r\n    \"type\": \"full\",\r\n    \"objects\": &#91;\r\n      {\r\n        \"database\": \"$DatabaseName\",\r\n        \"table\": \"$TableName\",\r\n        \"partition\": \"$PartitionName\"\r\n      }\r\n    ]\r\n  }\r\n}\r\n\"@\r\n\r\n# --------------------------------------------\r\n# Execute XMLA command\r\n# --------------------------------------------\r\n\r\nStep \"Connecting to XMLA endpoint\"\r\n\r\n$Server = New-Object Microsoft.AnalysisServices.Server\r\n$Server.AccessToken = $AmoAccessToken\r\n\r\n$ConnectionString = \"Data Source=$ServerName;Initial Catalog=$DatabaseName\"\r\n\r\n$Server.Connect($ConnectionString)\r\n\r\ntry {\r\n    Step \"Processing partition\"\r\n\r\n    $Server.Execute($Tmsl)\r\n\r\n    Write-Host \"\"\r\n    Write-Host \"Partition '$PartitionName' processed successfully.\" -ForegroundColor Green\r\n}\r\nfinally {\r\n    if ($Server.Connected) {\r\n        $Server.Disconnect()\r\n    }\r\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-11.png\"><img decoding=\"async\" loading=\"lazy\" width=\"940\" height=\"876\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-11.png\" alt=\"\" class=\"wp-image-1607\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-11.png 940w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-11-300x280.png 300w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2026\/05\/image-11-768x716.png 768w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This entire functionality only works with Fabric or Premium. The workspace must be configured accordingly. In the underlying SSAS cube (semantic model), the data is stored in corresponding partitions. The purpose here is not to improve performance, as known from &hellip; <a href=\"https:\/\/www.flip-design.de\/?p=1594\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.flip-design.de\/index.php?rest_route=\/wp\/v2\/posts\/1594"}],"collection":[{"href":"https:\/\/www.flip-design.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.flip-design.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.flip-design.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.flip-design.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1594"}],"version-history":[{"count":2,"href":"https:\/\/www.flip-design.de\/index.php?rest_route=\/wp\/v2\/posts\/1594\/revisions"}],"predecessor-version":[{"id":1608,"href":"https:\/\/www.flip-design.de\/index.php?rest_route=\/wp\/v2\/posts\/1594\/revisions\/1608"}],"wp:attachment":[{"href":"https:\/\/www.flip-design.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.flip-design.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.flip-design.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}