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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Change column name to use other column value

Hi All,

I want to change the column name and use other column values

The data table is shown below, the name of column SoldQtyLM uses LMdate value 202102, and the name of column SoldQtyMTD uses CMdate value 202103.

How should I modify it. Thank you.

 

twong_0-1615280898973.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Sorry that I misunderstood your requirement. Please copy and paste the updated codes into your Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMjQwUtKBMIzhDANzINMAjmN1RpXSRGksAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [LMdate = _t, CMdate = _t, CDate = _t, SoldQtyLM = _t, SoldQtyMTD = _t, SoldQtyCD = _t]),
    #"Renamed Columns" = Table.RenameColumns(Source,{{"SoldQtyLM",Source[LMdate]{0}},{"SoldQtyMTD",Source[CMdate]{0}},{"SoldQtyCD",Source[CDate]{0}}})
in
    #"Renamed Columns"

yingyinr_0-1615517237088.png

Best Regards

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @Anonymous ,

1. Do you want to keep all these 6 columns and replace the value of column SoldQtyLMSoldQtyMTD and SoldQtyCD with the value of column LMdata, CMdate and CDate separately? If yes, you can achieve it using function Table.ReplaceValue. Please copy and paste the following codes into your Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMjQwUtKBMIzhDANzINMAjmN1RpXSRGksAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [LMdate = _t, CMdate = _t, CDate = _t, SoldQtyLM = _t, SoldQtyMTD = _t, SoldQtyCD = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"LMdate", Int64.Type}, {"CMdate", Int64.Type}, {"CDate", Int64.Type}, {"SoldQtyLM", Int64.Type}, {"SoldQtyMTD", Int64.Type}, {"SoldQtyCD", Int64.Type}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",0,each [LMdate],Replacer.ReplaceValue,{"SoldQtyLM"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",0,each [CMdate],Replacer.ReplaceValue,{"SoldQtyMTD"}),
    #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1",0,each [CDate],Replacer.ReplaceValue,{"SoldQtyCD"})
in
    #"Replaced Value2"

replace values.JPG

2. If you want to only keep the column SoldQtyLM, SoldQtyMTD and SoldQtyCD with the values from the values of column LMdate, CMdata and Cdata, you can remove the column SoldQtyLM, SoldQtyMTD and SoldQtyCD first and rename the column LMdate, CMdata and Cdata as SoldQtyLM, SoldQtyMTD and SoldQtyCD just like below screenshot.

Rename columns.JPG

Best Regards

Anonymous
Not applicable

Hi Rena,

 

Thank you for your reply. I'm sorry maybe I didn't speak clearly enough. Just want to replace the Column name so that it can be displayed on the report. Thanks.

 

twong_0-1615450129257.png

Best Regards,

twong

Anonymous
Not applicable

Hi @Anonymous ,

Sorry that I misunderstood your requirement. Please copy and paste the updated codes into your Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMjQwUtKBMIzhDANzINMAjmN1RpXSRGksAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [LMdate = _t, CMdate = _t, CDate = _t, SoldQtyLM = _t, SoldQtyMTD = _t, SoldQtyCD = _t]),
    #"Renamed Columns" = Table.RenameColumns(Source,{{"SoldQtyLM",Source[LMdate]{0}},{"SoldQtyMTD",Source[CMdate]{0}},{"SoldQtyCD",Source[CDate]{0}}})
in
    #"Renamed Columns"

yingyinr_0-1615517237088.png

Best Regards

Anonymous
Not applicable

Hi @Anonymous 

Thanks for the quick response.

But there is still a issue. When I release a report for a new day, the date in the column name will change, and the report cannot recognize the column. How should I solve it?

 

Thank you once again.

 

 

Anonymous
Not applicable

Hi @Anonymous ,

Did you applied any other step after the step "Renamed Columns"? If yes, it may cause the problem. Please try to apply the other steps first and put the step "Renamed Columns" as the last step....

Best Regards

Anonymous
Not applicable

Hi @Anonymous 

 

The following is the report layout. When the second day is updated, due to the date conversion, the report cannot see the new day and an error occurs. Thanks.

twong_0-1616049817125.png

Regards,

twong

Anonymous
Not applicable

Hi @Anonymous ,

I'm afraid that there is no elegant method to fix this problem except delete the field with error and add the "new" field back to the visual. The field with old name is used in visual, it is static. And it can't update the field in the visual by sync after rename the field. You can raise a new idea and add your comments there to make this feature coming sooner. 

Best Regards

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.