Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hi,
I am using Microsoft.AnalysisServices.Tabular to alter the dataset via C# code.
i have a table called Table A and there is another Table Called Table A Custom, Now when i try to add a column in Table A Custom it also appears on Table A some how, I have debugged the whole case and have seen that through code it is only updating a single table Table A Custom.
// tables contain ['Table A Custom','Table B Custom']
for( tableName in tables){
var pbiTable = database.Model.Tables
.FirstOrDefault(x => x.Name.Equals(tableName, StringComparison.OrdinalIgnoreCase));
var pbiColumns = pbiTable?.Columns;
var fieldsToAdd = getFieldsFromDb();
fieldsToAdd.ForEach(field => AddField(field.Name, field.DataType, pbiColumns));
}
// Function to add the column
private void AddField(string fieldName, DataType fieldType, ColumnCollection pbiColumns)
{
if (pbiColumns == null)
{
return;
}
var newColumn = new Microsoft.AnalysisServices.Tabular.DataColumn
{
Name = fieldName,
DataType = fieldType,
SourceColumn = fieldName,
LineageTag = fieldName + "-" + Guid.NewGuid(),
};
pbiColumns.Add(newColumn);
}Note: This behaviour is intermittent, does not happen everytime i try to do, but it usually happens when i freshly publish the dataset to service and try to add fields to the table via code. also note sometimes the fields do not appear quickly but appears after a refresh to that dataset. i am unable to find the root cause for the same
Solved! Go to Solution.
Hi @v-priyankata ,
We had a procedure on dataset that would bind the columns they created dynamically to table or custom table, we had to point it to custom table in that procedure which could be one of the root cause of the issue,(So the code was trying to add to new table and the procedure pointed to old table and when we refreshed the dataset it would appear in 2 tables) anyways we are currently not facing the duplicate column issue for now after we changed the procedure to point to new table, but we are not sure if it would happen anytime again.
Hi @ChetanK004
Thank you for reaching out to the Microsoft Fabric Forum Community.
@Zanqueta Thanks for the inputs.
I hope the information provided by user was helpful. If you still have questions, please don't hesitate to reach out to the community.
Hi @ChetanK004
Hope everything’s going smoothly on your end. I wanted to check if the issue got sorted. if you have any other issues please reach community.
Hi @v-priyankata ,
We had a procedure on dataset that would bind the columns they created dynamically to table or custom table, we had to point it to custom table in that procedure which could be one of the root cause of the issue,(So the code was trying to add to new table and the procedure pointed to old table and when we refreshed the dataset it would appear in 2 tables) anyways we are currently not facing the duplicate column issue for now after we changed the procedure to point to new table, but we are not sure if it would happen anytime again.
Hi @ChetanK004
We appreciate your efforts and thank you for keeping us informed about the update on this issue. If you encounter any further issues, please do not hesitate to reach out to the community. We also encourage you to continue using the Fabric Community forum for any future assistance.
Hi @Zanqueta , Thanks for the response, For the below root causes
var pbiTable = database.Model.Tables
.FirstOrDefault(x => x.Name.Equals(tableName, StringComparison.OrdinalIgnoreCase));
if (pbiTable == null)
throw new Exception($"Table {tableName} not found.");Add columns safely
private void AddField(string fieldName, DataType fieldType, ColumnCollection pbiColumns)
{
if (pbiColumns == null) return;
var newColumn = new Microsoft.AnalysisServices.Tabular.DataColumn
{
Name = fieldName,
DataType = fieldType,
SourceColumn = fieldName
};
pbiColumns.Add(newColumn);Use the recomended refresh method and order For schema changes:
Model.RequestRefresh(RefreshType.Full);
database.Model.SaveChanges();
References:
Model.RequestRefresh Method (Microsoft.AnalysisServices.Tabular) | Microsoft Learn
Please, let me know if it worked.
If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn
Hi @ChetanK004,
This behaviour is related to how Microsoft.AnalysisServices.Tabular manages object references in the Tabular Object Model (TOM). When you add a column to a table, the change is applied to the in-memory model, and then persisted when you call Model.SaveChanges(). If columns appear in another table, it usually indicates one of the following:
Please, look at steps bellow an try:
var pbiTable = database.Model.Tables
.FirstOrDefault(x => x.Name.Equals(tableName, StringComparison.OrdinalIgnoreCase));
if (pbiTable == null)
throw new Exception($"Table {tableName} not found.");
var pbiColumns = pbiTable.Columns;database.Model.SaveChanges();If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |