Forum Discussion
Anonymous
4 years agoNot applicable
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. ...
- 4 years ago
Anonymous,
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.
DataInsights
4 years agoSuper User
Anonymous,
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.