Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
julio_gago_alon
Frequent Visitor

cosmos v1 to v2

Hi!

 

I have a bunch of reports & semantic models in powerbi.com that were generated from desktop using cosmos db v1 connector, that is, the advanced editor shows "DocumentDB.Contents.(...)" in the very first step.

 

I need to move to v2 connector which means using CosmosDB.Contents(). I managed to do that by replacing the initial commands in the advanced editor to the ones inserted by the application when I connect to a new v2 from scratch.

 

I can make both compatible with a few edits, with that I mean that I can migrate a report based on v1 to v2 with a few edits.

 

However, my issue is currently this: v2 connector will automatically expand JSON documents, which is ok, but it will prefix the columns with the name of the field being expanded, which is a bummer, because then I have to manually replace all the names of the previous expansion, one by one, and also in the visuals.

 

That is a no-go.

 

So I am wondering if there is any method to disable that prefixing of column names during the expansion, so that I can end up having the same column names as before, where I selected the option to NO do any prefixing.

 

Thanks,

Julio.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @julio_gago_alon ,
Your problem is that the V2 connector prefixes column names when extending JSON, right?

Here is the solution I found for you hope it helps!
1. Custom Transformation in the Query Editor:
You can use the “Rename Columns” function to map the new prefixed column names back to the original ones.
his can be done manually for a small number of columns or programmatically using M code for large datasets.
Example M code snippet for renaming columns:

Table.RenameColumns(
Source,
{
{"prefixed_column1", "original_column1"},
{"prefixed_column2", "original_column2"}
}
)

2. Preventing Prefixing During Expansion:
Unfortunately, in Power BI, the V2 Cosmos DB connector does not provide a direct option to disable the prefixing behavior.
A possible workaround is to modify the M query after expansion:
Use Table.TransformColumnNames to remove prefixes.
Example:

Table.TransformColumnNames(Source, each Text.Replace(_, "prefix_", ""))


3. Automation for Large Models:
• If the renaming needs to be applied across multiple queries or tables:
• Create a parameterized M script to dynamically detect and remove prefixes from column names.
• Example:

let
RemovePrefixes = (table as table, prefix as text) =>
Table.TransformColumnNames(table, each Text.Remove(_, prefix))
in
RemovePrefixes

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

2 REPLIES 2
julio_gago_alon
Frequent Visitor

Awesome set of solutions! Thanks

Anonymous
Not applicable

Hi @julio_gago_alon ,
Your problem is that the V2 connector prefixes column names when extending JSON, right?

Here is the solution I found for you hope it helps!
1. Custom Transformation in the Query Editor:
You can use the “Rename Columns” function to map the new prefixed column names back to the original ones.
his can be done manually for a small number of columns or programmatically using M code for large datasets.
Example M code snippet for renaming columns:

Table.RenameColumns(
Source,
{
{"prefixed_column1", "original_column1"},
{"prefixed_column2", "original_column2"}
}
)

2. Preventing Prefixing During Expansion:
Unfortunately, in Power BI, the V2 Cosmos DB connector does not provide a direct option to disable the prefixing behavior.
A possible workaround is to modify the M query after expansion:
Use Table.TransformColumnNames to remove prefixes.
Example:

Table.TransformColumnNames(Source, each Text.Replace(_, "prefix_", ""))


3. Automation for Large Models:
• If the renaming needs to be applied across multiple queries or tables:
• Create a parameterized M script to dynamically detect and remove prefixes from column names.
• Example:

let
RemovePrefixes = (table as table, prefix as text) =>
Table.TransformColumnNames(table, each Text.Remove(_, prefix))
in
RemovePrefixes

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.