Converting a Direct Lake model to Import
One of my favorite features of Tabular Editor (both 2 and 3) is its C# scripting capability
I have always been a huge fan of productivity tools
Just yesterday, a user asked if Tabular Editor could help convert a Direct Lake model to an Import-mode model. This isn't an out-of-the-box feature, as this requirement is quite rare. However, when the need arises, performing this conversion manually would be incredibly cumbersome and tedious—especially if the model is large and contains many tables.
Enter C# scripting! Without further ado, here's the script (click the link below to see the code):
Copy and paste this script into TE2/TE3's C# script editor and run it on a Direct Lake-mode model. It will convert all Direct Lake partitions to their equivalent Import partitions and reset the model collation to its default value (since Direct Lake models are case-sensitive regarding data).
You can run the script while Tabular Editor is connected to a semantic model through the XMLA endpoint. However, you likely won't be able to save the changes back to the Power BI / Fabric workspace, as in-place conversion of Direct Lake models to Import models is not supported. Instead, you can use the Model > Deploy... option to deploy the newly converted model
Note: After deploying the newly converted Import-mode model, you will need to specify the credentials for accessing the Lakehouse to refresh data into the model. In the Power BI / Fabric workspace, click the ellipsis button next to the model and choose "Settings":
领英推荐
Then, expand the "Data source credentials" section and click "Edit credentials
In my case, setting the Authentication method to "OAuth2", choosing "Public" for the Privacy level setting for this data source, and then hitting Sign in, was all that was needed.
And lo and behold, our Import-mode model can now be refreshed:
Scalable BI Solutions | Freelance BI Consultant
6 个月Incredible! Using an ever expanding collection of C# scripts in Tabular Editor when working on a semantic model never stops feeling magical????♂?.
Microsoft Fabric Architect | Business Intelligence Architect | Microsoft Data Platform MVP | Power BI Super User | Speaker | Mentor | Technical Business Strategist | Author
7 个月incredible!!!
Serving "a la carte" DAX dishes or data buffets from a kitchen with Power BI and Azure Data Platform.
7 个月????That's another awesome usecase for Tabular Editor's C# Scripting functionality. Daniel, thank you for sharing!