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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Goodkat
Helper I
Helper I

Case insensitive column rename with mapping table

Dear friends of Power Query,

 

With the help of the forum, and two insightful websites (a big, big thank you to Imke Feldman thebiccountant.com and Rick de Groot gorilla.bi) I was able to further improve my data flows. Especially having unified naming of column names, disregardless from which chaotic source they are from, makes all following steps much easier. Hence, over the last days I came up with a long list of renamings and realized that doing this case insensitive would be beneficial as it reduces the number of master data entries I need to look after.

So with the help of Rick de Groot's Tutorial I managed a crisp case insensitive renaming of items when they are in a list.

 

Yesterday I reviewed another information source in which it does make most sense to replace directly in the column names. I thought to use the replacement in a list and implement it into the Table.TransformColumnNames.

And here I fail. I have tried since two hours various possible constellations which I have used on header renaming in the past; but without success. I also tried to combine it into a Table.RenameColumns, but never got it running.

 

Does anyone from the community have an idea how to use the replacement logic that works properly case insensitive also in a direct renaming of column names?

https://c.gmx.net/@324888734501700174/z3Eoy1QdSoyMiT3Bx-LraA

 

I am eager to learn, how I would need to adapt the code!

 

Thank you a lot in advance!

 

Best regards, Andreas

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Use this as your next step

= Table.TransformColumnNames(Quelle, (x)=>try mdTable[NewText]{List.PositionOf(mdTable[OldText], x, 0,Comparer.OrdinalIgnoreCase)} otherwise x)

View solution in original post

2 REPLIES 2
Goodkat
Helper I
Helper I

Dear Vijay,

it works perfect. Brilliant! I have never seen the 'try' / 'otherwise' commands before!

Good learning! And the headers are now as they are supposed to.

 

Thank you so much!

Best regards, Andreas

Vijay_A_Verma
Super User
Super User

Use this as your next step

= Table.TransformColumnNames(Quelle, (x)=>try mdTable[NewText]{List.PositionOf(mdTable[OldText], x, 0,Comparer.OrdinalIgnoreCase)} otherwise x)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors