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
Eric7
Resolver II
Resolver II

Simplyfy multiple calls to Table.ReplaceValue

Hi, I wonder if it is possible to simplyfy multiple calls to Table.ReplaceValue by creating one function?

 

Here are 3 calls to Table.ReplaceValue:

#"Encode Id" = Table.ReplaceValue(Source, each [Tenant Id], each fnc_ATS_Encode_Id([Tenant Id], pTR),Replacer.ReplaceValue,{"Tenant Id"}),
#"Encode Id2" = Table.ReplaceValue(#"Encode Id", each [Department Id], each fnc_ATS_Encode_Id([Department Id], pTR),Replacer.ReplaceValue,{"Department Id"}),
#"Encode Id3" = Table.ReplaceValue(#"Encode Id2", each [Parent Department Id], each fnc_ATS_Encode_Id([Parent Department Id], pTR),Replacer.ReplaceValue,{"Parent Department Id"}

 

It would be nice to have a function like below taking only the table and a list of the 3 column names as parameters:
#"Encode Id" = fnc_ATS_EncodeCols(Source, {{"Tenant Id"}, {"Department Id"}, {"Parent Department Id"}})

which then calls Table.Replace for each of the columns specified in the paramter list.

 

My attempt to use

col = Table.Column("Tenant Id") to get the col inside fnc_ATS_EncodeCols() to use as [col] did not succeed...

 

 

Eric

 

 

 

1 ACCEPTED SOLUTION
Smauro
Solution Sage
Solution Sage

Hi @Eric7 

 

You could just transform each column in one line, but I do find Table.ReplaceValue to work a bit faster.

Try this:

Table.ReplaceValue(
    Source, nullnull,
    (x, y, z) => fnc_ATS_Encode_Id(x, pTR),
    { "Tenant Id""Department Id""Parent Department Id" }
)

 




Spyros Mavroforos

Data Consultant


Find me on LinkedIn or drop me an email

eSpyros

View solution in original post

2 REPLIES 2
Smauro
Solution Sage
Solution Sage

Hi @Eric7 

 

You could just transform each column in one line, but I do find Table.ReplaceValue to work a bit faster.

Try this:

Table.ReplaceValue(
    Source, nullnull,
    (x, y, z) => fnc_ATS_Encode_Id(x, pTR),
    { "Tenant Id""Department Id""Parent Department Id" }
)

 




Spyros Mavroforos

Data Consultant


Find me on LinkedIn or drop me an email

eSpyros

Thank you so much, my friend! Works perfectly.

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.