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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ThomasSan
Helper IV
Helper IV

Replace text with content from other column

Hi everyone,

 

I am attempting to dynamically replace the headers of my table. My headers contain the string BLY, LY and CY which stand for "Before Last Year", "Last Year" and "Current Year", respectively. 

 

My steps so far were as follows:

- Managed to modify Excel data file so it contains the rows with the desired replacement values (i.e. 2019, 2020 and 2021)

- Transposed my table (before setting the first row as my column headers) so that I have all my column headers listed in one row (see screenshot)

ThomasSan_0-1638525087702.png

- Using the "Replace Values" button, I have created the formula 

= Table.ReplaceValue(#"Transposed Table","BLY","2019",Replacer.ReplaceText,{"Column1"})

which successfully replaces all BLY to 2019

 

 

Now, as I would prefer to not change my hard coded replacement value each year when the corresponding years of BLY, LY and CY change, I would like to have my headers changed dynamically. I therefore attempted to modify the formula above with 

= Table.ReplaceValue(#"Transposed Table","BLY",{32}[Column2],Replacer.ReplaceText,{"Column1"})

However, my result was as follows:

ThomasSan_1-1638525277889.png

 

It seems that this is not a viable option. Can someone please help me find the correct formula in order to produce the desired result?

1 ACCEPTED SOLUTION

What is the error message?

 

If it's complaining that 2019 isn't text, then you can wrap #"Transposed Table"{30}[Column2] with Text.From.

View solution in original post

4 REPLIES 4
AlexisOlson
Super User
Super User

The error is because it thinks you're trying to reference the Column2 field of the single element list { 32 }.

 

I think this is what you intended:

= Table.ReplaceValue(#"Transposed Table","BLY",#"Transposed Table"{30}[Column2],Replacer.ReplaceText,{"Column1"})

Hi @AlexisOlson ,

 

thank you for your reply. You are right, {32} was an error. Having applied your formula, however, I only get errors generated in column1.

ThomasSan_0-1638700773032.png

Do you have any idea where the problem lies?

 

P.S.: = #"Transposed Table"{30}[Column2] is at least generating the right value (i.e. 2019)

ThomasSan_1-1638700917822.png

 

What is the error message?

 

If it's complaining that 2019 isn't text, then you can wrap #"Transposed Table"{30}[Column2] with Text.From.

@AlexisOlson 

great, that was the final key! Thanks a lot for your help!

 

 

for others

the final formula should read 

 

= Table.ReplaceValue(#"Transposed Table","BLY",Text.from(#"Transposed Table"{30}[Column2]),Replacer.ReplaceText,{"Column1"})

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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 Kudoed Authors