Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I am trying to load data into a semantic model in C# using the TOM model in import mode. I have tried these 2 approaches so far and both have resulted in the table being created with no data:
1. ODBC: set up an ODBC on my local windows and tested that the credentials are valid and it is able to connect. I used the same credentials in the code but it is not able to fetch the data
2. Import-mode table using Power Query's native Snowflake connector (ADBC): using the power query method of connection and MPartitionSource.
Both methods are creating the table in the model but the table is empty with no columns or data when I check in the service.
Are there any alternative/easier method to load data from snowflake tables into a semantic model? I have to do it in a programmatic way.
Thank you in advance for any advice.
Solved! Go to Solution.
Hi @sresan477
Sorry for the inconvenience caused for your issue.Can you please raise a Microsoft support ticket. You can create a Microsoft support ticket using the link below.
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn
If this helps, then please Accept it as a solution and dropping a "Kudos" so other members can find it more easily.
Hope this works for you!
Thanks.
Hi @sresan477
Would you mind sharing the approach you used to resolve the issue with the microsoft support ticket? It would be helpful to others facing a similar situation. If possible, kindly post your solution in this thread so the community can benefit from it.
Thanks again for your contribution!
As per Microsoft community guidelines, we will now proceed to close this thread to keep discussions focused and manageable. If you still need assistance, you're welcome to start a new thread in the community at any time.
We appreciate your understanding and participation.
Best Regards,
Cheri Srikanth
Hi @sresan477
Sorry for the inconvenience caused for your issue.Can you please raise a Microsoft support ticket. You can create a Microsoft support ticket using the link below.
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn
If this helps, then please Accept it as a solution and dropping a "Kudos" so other members can find it more easily.
Hope this works for you!
Thanks.
Hi @sresan477
I wanted to follow up since I haven't heard from you in a while. Have you had a chance to try the suggested solutions?
If your issue is resolved, please consider marking the post as solved. However, if you're still facing challenges, feel free to share the details, and we'll be happy to assist you further.
Looking forward to your response!
Best Regards,
Community Support Team _ C Srikanth.
Hi @sresan477
Thanks for the clarification. Since you've confirmed that the Snowflake connection is established and returns session info, the issue likely lies in how the M query is evaluated or how schema discovery is handled when building the model programmatically.
Please check that the M query you're assigning to the MPartitionSource returns a table structure with clearly defined rows and columns. A common reason for empty tables appearing in the semantic model is that the query resolves to something other than a table (like a list or a scalar), or the schema isn’t being inferred correctly. You can test this by pasting the same M query into Power BI Desktop's Advanced Editor to validate that data loads as expected.
If you're using Snowflake.Databases() or Snowflake.Contents(), make sure the expression navigates all the way to the actual table and returns the data.
In some cases, setting [InferSchema=true] as a parameter in the connector helps resolve missing columns during schema inference. You may also try manually defining the expected columns in TOM before processing the table.
Lastly, don’t forget to explicitly call RequestRefresh(RefreshType.Full) on the partition and then commit changes using model.SaveChanges() this is essential to trigger the actual data load into the model.
If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.
I have tried the given method and it is the same issue. The table is created but it has no data in it:
for your reference, this is the M Expression I am using:
var mExpr = $@"
let
Source = Snowflake.Databases(""{SfAccount}"",
[ Warehouse=""{SfWarehouse}"",
Database=""{SfDatabase}"",
Schema=""{SfSchema}"",
Role=""{SfRole}"",
InferSchema=true ]),
TableData = Source{{ [Name=""{SfTableName}"",Kind=""Table""] }}[Data]
in
TableData";
I have tried the method to create a snowflake data source first using M Snowflake Connector, but as I am connecting to the Power BI Service, it is not able to create the data source at all.
I have found that I do not need to create a data source when creating in the service as the M Expression used to load the data (given above) will implicity create the connection. Is this accurate?
Here is the way I have created the Data Source:
var sfDs = new StructuredDataSource { Name = "SnowflakeConnector" };
var connJson = $@"{{
""protocol"": ""Snowflake.Databases"",
""address"": {{
""account"": ""{SfAccount}"",
""warehouse"": ""{SfWarehouse}"",
""database"": ""{SfDatabase}"",
""schema"": ""{SfSchema}""
}}
}}";
var credJson = $@"{{
""authenticationKind"": ""UsernamePassword"",
""username"": ""{SfUsername}"",
""password"": ""{SfPassword}"",
""encryptConnection"": true
}}";
var sfDs = new StructuredDataSource { Name = "SnowflakeConnector" };
sfDs.ConnectionDetails = new ConnectionDetails(connJson);
sfDs.Credential = new Credential(credJson);
model.DataSources.Add(sfDs);
model.SaveChanges();
Hi @sresan477
Thank you for being part of the Microsoft Fabric Community.
You are correct that programmatically loading data from Snowflake into a Semantic Model (using TOM and C#) in Import mode can be challenging, and empty tables or missing data usually indicate either a connection misconfiguration or an unsupported approach.
The Tabular Object Model (TOM) manages semantic model objects, but actual data import is handled through defined data sources and requires explicit process operations (ProcessFull, ProcessData, etc.). Snowflake is supported as a data source for semantic models in Power BI and Fabric, but programmatic connections in TOM must use the native Power Query/M connector (not legacy ODBC). Use MPartitionSource in your partition definition and make sure your M query is correct and returns data.
Please do folow the below steps:
Create a Data Source in the model using the M (Power Query) Snowflake connector.
Define a Table with a partition that references the M data source.
Process the Table/Partition using ProcessFull to load data into the semantic model.
Common reasons for empty tables include forgetting to call ProcessFull or ProcessData after table creation, issues with the M query or connector string, and insufficient permissions or an unsupported authentication method.
References:
If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.
thanks for the response. I have tried the following method and have gotten the same result. The table is being created but there are no columns or rows in it. Before loading the columns, I even included a check which queried the snowflake db for current session info to make sure that the connection is being established. That query worked just fine.