Monday, December 5, 2022

A No-Code Method to Refresh One Table From a Power BI Dataset in the Service

Context

A few weeks back I was working on a dataset at a client where I needed to import Excel files from a folder into said dataset. I filtered the files on a prefix and loaded around 30 files of the same structure to a table in my dataset. The Excel files are exports from a budgetting system (I know, right?) that have to be updated multiple times in the next coming weeks on an ad-hoc basis.

After the Excel files are updated I currently have 2 choices:

  • Open the pbix-file and refresh the specific table that loads the files, and then publish to the service. This however again triggers a refresh in the service after publishing. Depending on the connection I have in the pbix (subset of rows from dev/test/prod) I might have to wait for the refresh in the service anyhow
  • Refresh the dataset in the service and wait for that to finish
And it's not that the dataset is thát big, but of course waiting (for 20 to 30 minutes) for a refresh would be a waste of time. And it doesn't really matter how long it exactly takes, if you're waiting for something, it always takes too long, right?

Solution

But as you might have noticed from the title of this blog, there is also another solution 😀.
Spoiler alert: you do need a Premium license.

Marc Lelijveld previously talked about the automation of triggering a single table to refresh in the Power BI Service, with PowerShell and a TMSL script. 

But what if you're not (that) familiar with PowerShell and / or TMSL? And maybe it's not going to be part of an automated schedule, but you just want to be able to execute it ad-hoc, when necessary?

Luckily there's the XMLA endpoint to the rescue. You can connect to any Premium (Capacity or Per User) workspace via the XMLA endpoint with SQL Server Management Studio (SSMS) to do a (single) table refresh.


There's a few things you'll have to consider before being able to do this..

  • Enable XMLA read-write
  • Get the XMLA endpoint connection string
  • Connect via SSMS
  • Refresh your table(s)
  • Check the outcome of the refresh in SSMS
    • Or alternatively check the refresh history in the service
Let's look at the individual steps in more detail.

Enable XMLA read-write



The first thing you need to do is to enable the option Read Write on the XMLA Endpoint of your Premium capacity.

This setting is available in the Admin Portal, either under Capacity settings or Premium Per User, depending on your license.




XMLA Endpoint connection












You can get the connection URL from the workspace Settings page, under the Premium tab.
More info on the documentation page.

Note: Connecting to a My Workspace by using the XMLA endpoint is currently not supported.













Connect via SSMS


Use SQL Server Management Studio to connect to the URL obtained in the previous step. Just be aware that you need version 18.9 or higher to do so.



Make sure you use the following option for Authentication:
  • Azure Active Directory - Universal with MFA
Next to connecting to and looking at properties of your Power BI models, this method also supports executing DAX, MDX, and XMLA queries.

SSMS isn't the only tool supported by the XMLA endpoint, you can pick any of the tools mentioned here, e.g. Excel, SQL Server Profiler, DAX Studio or Tabular Editor to name a few of them.


With some tools it might be necessary to also provide the Initial Catalog (the dataset to connect to in your workspace). The datasets in your workspace will eventually show as databases under your AS-server:



UPDATE December 19th 2022:
When using SSMS and the option to use an Initial Catalog, you (might) run into an error, read my update post how to avoid this.

Refresh your table(s)


Now onto the actual refreshing of my tables. 
  • Right-click the table you want to refresh and select Process Table


  • Select the right processing option depending on your needs, I used a full refresh
  • Optionally select other tables to refresh
  • Click OK and wait for the refresh to complete.



Next to refreshing your table(s) in SSMS, you could also script out the refresh command and use it to automate the process. Because I only need to refresh it on an ad-hoc basis I'm good with my solution for now.



Refresh history


This type of refresh shows as a Via XMLA Endpoint in the Refresh History of your dataset properties in the service.



In any case you ever want to cancel a running refresh, also with Premium and the XMLA endpoint set to Read/Write, have a look at this post how to Cancel a refresh with a SessionID (instead of SPID) and DAX Studio.


Conclusion


In this post I provided a UI-only solution to refreshing a single table in your Power BI dataset. Hopefully this post gave you some insights.
Have you already used this method before?
Do you use it often?
Do you use other methods to refresh a table in a dataset?

I'd love it when you provide more details in the comments!



5 comments:

  1. Hi Nicky, Thanks for sharing this. But I don't understand how it is better than the refresh option from the Service. Does it take less time to refresh?

    ReplyDelete
    Replies
    1. Thanks for that question. My case is to refresh a single table (so not the whole dataset). If your dataset contains many tables, and some very large, it might take a while to refresh the whole dataset. I only needed to refresh the Excel files for my dataset, so that 1 table was enough for me.
      Also refreshing the whole dataset puts more burden on the source (in this case a DWH).

      Delete
  2. I'd like to be able to do this but I get an error when I try this.

    "paramter name already exists
    Parameter name: name (Microsoft.AnalysisServices.BackEnd)"

    ReplyDelete
    Replies
    1. Ha, I actually also got that one :-) Read up on my update here how to fix that: https://www.nickyvv.com/2022/12/ssms-error-when-refreshing-power-bi-table-paramter-name-already-exists.html

      Delete
    2. Sorry, I missed that. Works perfectly now!

      Delete

Thanks for taking the time to provide feedback!

Cheers,
Nicky