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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
IvayloKanov
New Member

Problem with replace in new filtered Table

Hi Friends.
I am new in PowerBi and I am very ambitious because that is very interesting for me.
For two days I have issue with one formula in DAX and really need your help.
Idea is that: I take some filtered data from one Master Table and want to change after that values in the new Table, but i can't.
Table =
var filteredTable = FILTER('BI FIN_ELEMENTS','BI FIN_ELEMENTS'[SortID] in {"070i", "080i"})var replacedTable = Table.ReplaceValue("070i", "330i")return replacedTable
1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @IvayloKanov 

 

To get your expected result, you can use Power Query only. First filter SortID column, then replace values in it. These are basic operations that can be done with the User Interface in Power Query Editor. You will then see the auto generated M code of a step in the formula bar. You can also open Advanced Editor in Home ribbon to see the complete M code of the whole query. 

vjingzhang_0-1645507542466.png

Power Query Reference: 

Filter by values in a column - Power Query | Microsoft Docs

Replace values and errors - Power Query | Microsoft Docs

 

If you want to do this with DAX, after getting the filtered table, you can add a new column to have the new values as DAX doesn't have replace feature. Then select the columns you want to return. 

Table 2 = 
var filteredTable = FILTER('Table','Table'[SortID] in {"070i", "080i"})
var replacedTable = ADDCOLUMNS(filteredTable,"new_ID",IF('Table'[SortID]="070i","330i",'Table'[SortID]))
var newTable = SELECTCOLUMNS(replacedTable,"SortID",[new_ID],"Value",[Value])
return 
newTable

vjingzhang_1-1645509034485.png

DAX funtions:

ADDCOLUMNS function (DAX) - DAX | Microsoft Docs

SELECTCOLUMNS function (DAX) - DAX | Microsoft Docs

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @IvayloKanov 

 

To get your expected result, you can use Power Query only. First filter SortID column, then replace values in it. These are basic operations that can be done with the User Interface in Power Query Editor. You will then see the auto generated M code of a step in the formula bar. You can also open Advanced Editor in Home ribbon to see the complete M code of the whole query. 

vjingzhang_0-1645507542466.png

Power Query Reference: 

Filter by values in a column - Power Query | Microsoft Docs

Replace values and errors - Power Query | Microsoft Docs

 

If you want to do this with DAX, after getting the filtered table, you can add a new column to have the new values as DAX doesn't have replace feature. Then select the columns you want to return. 

Table 2 = 
var filteredTable = FILTER('Table','Table'[SortID] in {"070i", "080i"})
var replacedTable = ADDCOLUMNS(filteredTable,"new_ID",IF('Table'[SortID]="070i","330i",'Table'[SortID]))
var newTable = SELECTCOLUMNS(replacedTable,"SortID",[new_ID],"Value",[Value])
return 
newTable

vjingzhang_1-1645509034485.png

DAX funtions:

ADDCOLUMNS function (DAX) - DAX | Microsoft Docs

SELECTCOLUMNS function (DAX) - DAX | Microsoft Docs

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

BA_Pete
Super User
Super User

Hi @IvayloKanov ,

 

You're mixing up two different languages here.

 

This part is DAX:

_myMeasure =
VAR __myVar = something
RETURN
__myVar

 

This part is M:

Table.ReplaceValue(arg1, arg2, arg3, arg4, arg5)

 

I appreciate your ambition, but you should get acquainted with the absolute basics first. Try these to get you going:

 

DAX:

https://support.microsoft.com/en-us/office/quickstart-learn-dax-basics-in-30-minutes-51744643-c2a5-4... 

 

Power Query/M:

https://docs.microsoft.com/en-us/powerquery-m/quick-tour-of-the-power-query-m-formula-language 

https://radacad.com/basics-of-m-power-query-formula-language 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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