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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Saniat
Helper V
Helper V

How do I replace a field/column/measure/reference throughout my pbi file

Hi,

In my report I have a field e.g. HC_field.

Based on this field I have created a measure HC_measure.

HC_measure is used in several visuals, and other calculations/measures in the report.

Later during my development, I have realised that a new field HC_field2 is more accurate for the HC_measure calculation.

How do I replace    HC_field    with    HC_field2    in a way so all the references (i.e. measures and visuals) to    HC_field     will now refer to     HC_field2 ?

In case I decide to create a new measure HC_measure2, and want all my visuals to use    HC_measure2     instead of    HC_measure - how do I do that ?

Many thanks

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Saniat,

 

You can replace the column name in all measures by using the following script in Tabular Editor (Advanced Scripting tab):

 

var FromString = "HC_field";
var ToString = "HC_field2";
foreach (var m in Model.AllMeasures)
    {
        m.Expression = m.Expression.Replace(FromString,ToString);
    }

 

https://exceleratorbi.com.au/edit-replace-code-inside-all-dax-measures-using-tabular-editor/ 

 

I'm not aware of a way to programmatically swap fields in visuals.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@Saniat,

 

You can replace the column name in all measures by using the following script in Tabular Editor (Advanced Scripting tab):

 

var FromString = "HC_field";
var ToString = "HC_field2";
foreach (var m in Model.AllMeasures)
    {
        m.Expression = m.Expression.Replace(FromString,ToString);
    }

 

https://exceleratorbi.com.au/edit-replace-code-inside-all-dax-measures-using-tabular-editor/ 

 

I'm not aware of a way to programmatically swap fields in visuals.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors