Transform Column Names in Bulk in Power Query

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ธ.ค. 2024

ความคิดเห็น • 65

  • @BIGorilla
    @BIGorilla  ปีที่แล้ว +1

    To learn more about the syntax of Table.RenameColumns, make sure to check out: powerquery.how/table-renamecolumns/

  • @pravinshingadia7337
    @pravinshingadia7337 2 ปีที่แล้ว +5

    One of the best channels on power query around - well done

  • @lpenatti
    @lpenatti 2 ปีที่แล้ว +3

    This is the kind of video I love to watch, well explained, useful and powerful! Thanks for sharing it

  • @andrewwood6000
    @andrewwood6000 ปีที่แล้ว

    THANK YOU! Used this to help rename a column to a new name if it contained a word in the original name.

  • @KhajonsakLun
    @KhajonsakLun 2 ปีที่แล้ว +1

    Thank you very much from Thailand. I really like these technics.

  • @ExcelInstructor
    @ExcelInstructor ปีที่แล้ว +2

    and here is my method to Transform column types dynamicly :)
    Table.TransformColumnTypes(Source,
    Table.ToColumns(
    Table.Transpose(
    Table.AddColumn(
    Table.FromList(
    Table.ColumnNames( Source )), "Type",
    each
    if
    Text.Contains(Text.Lower([Column1]), "date")
    then
    type date
    else
    type text))))

  • @navisalomi
    @navisalomi ปีที่แล้ว +1

    Amazing vid. The Table.TransformColumnNames fx was a bomb.

  • @txreal2
    @txreal2 2 ปีที่แล้ว +1

    May I ask how come you always use PascalCase in renaming your query steps?
    Just curious 🤔

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว +2

      When you reference a step without spaces you can simply write its name.
      So referencing TableName can be done with TableName.
      Yet when there’s a space or special character you need extra formatting
      Referencing Table Name requires you to write #”Table Name”.
      I feel it’s easier to use PascalCase for the clarity of the code 🙏

    • @txreal2
      @txreal2 2 ปีที่แล้ว

      @@BIGorilla Thanks for your prompt & helpful answer.

  • @kristianbras
    @kristianbras 11 หลายเดือนก่อน

    Bedankt Rick! Echt top dat je deze video hebt gemaakt. Op dik 60 kolommen scheelt me dit een hoop tijd ;)

  • @paulgallagher2987
    @paulgallagher2987 2 ปีที่แล้ว +1

    This is brilliant and will save me so much time. Thank you. :)
    And as an added bonus it all folds.

  • @wimmosterdijk
    @wimmosterdijk ปีที่แล้ว

    awesome. definatly need to invest more time in Power Query as there is so much to gain

  • @gospelmoto2833
    @gospelmoto2833 2 ปีที่แล้ว +1

    excellent indeed! but a little complex.

  • @ThepExcel
    @ThepExcel 2 ปีที่แล้ว

    Clever solution! Thx

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว +1

      Glad you like it 👏

  • @angelaisland4036
    @angelaisland4036 2 ปีที่แล้ว +1

    Great information! Thank you

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว

      Glad it was helpful!

  • @VipinThakur
    @VipinThakur 2 ปีที่แล้ว +4

    Amazing video. Little complex but you explained it very well. Thanks for sharing. You got a subscriber 😊

  • @charliemcpherson2496
    @charliemcpherson2496 2 ปีที่แล้ว

    Can this be done while maintaining a DirectQuery connection? Adding the steps to my query prompts a message "This step results in a query that is not supported in DirectQuery mode". Any alternative to maintain DirectQuery capabilities?

  • @debbie6085
    @debbie6085 2 ปีที่แล้ว +1

    Great video. Thanks for that.

  • @funriderhoermi
    @funriderhoermi ปีที่แล้ว

    Amazing how easy life can be when you know where to look. Referring to the last part of your video on the subject of dates. How can I replace header with correct floating date. Belowan example:
    Is there a way to use a wildcard in functions. Example: "Thur 20-Apr €" is the text. I would like to search as follows: find "Thur wildcard €" and then I want to replace it with "Thur €". In addition, this should be possible for multiple promoted headers.
    Best Hans

  • @JvdWaa
    @JvdWaa ปีที่แล้ว

    Suggestions for the scenario where I start with snake_case and then replace the "_" with " " (this I know) and then want to capitalize only the very first word. ie, "sales_item" transformed to "Sales item".

    • @BIGorilla
      @BIGorilla  ปีที่แล้ว

      Hi JvdWaa - I would change the code to:
      = Table.TransformColumnNames(
      Source, each
      Text.Upper( Text.Start(_,1) ) &
      Text.Range( Text.Replace( _, "_", " " ), 1 ) )
      You can read more on both functions here:
      powerquery.how/text-upper/
      powerquery.how/text-range/
      Cheers!

    • @JvdWaa
      @JvdWaa ปีที่แล้ว

      @@BIGorilla Thanks!!!!

  • @erivaldolopes632
    @erivaldolopes632 ปีที่แล้ว

    how can I rename table column names with their position in the table rather than the actual column names' list?
    for example:
    col1 | col2 | col3 | col4 ....
    x | y | z | w .....
    so, rename columns, col1, col2, etc. based on their position {0, 1 , 2, 3} to {target1, target2, target3, target4, ....}

  • @txreal2
    @txreal2 2 ปีที่แล้ว

    Thanks 🙏Rick!
    Would you have time to do a video on bulk replace in the data rows (instead of manual Conditional Column with multiple if...then...else if..)?
    I often copy & paste multiple if..then.. else if in PQ Editor, and just change the text for each, like below
    each if Text.Contains([Column1], "Old Text ") then "New Text"
    else if Text.Contains([Column1], "Old Text2") then "New Text2"
    else if ...
    else null)

  • @Morgenj
    @Morgenj 2 ปีที่แล้ว

    Great Video Rick

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว

      Thanks Johan 🙏

  • @dirkstaszak4838
    @dirkstaszak4838 2 ปีที่แล้ว +1

    Interesting, I use a different way in order to be even more flexible, I have set up a column table, where I can steer if all columns or only a few are used and of course the name of the column can be set too. That gives the opportunity to use one data extract for different purposes

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว +1

      Hi Dirk! I’m interested in learning more. Do you have a separate table with column names so you can merge them and do a lookup what renaming should happen?
      How do you configure this in practice?

    • @dirkstaszak4838
      @dirkstaszak4838 2 ปีที่แล้ว +1

      @@BIGorilla sure how we gonna do this?

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว +1

      Can you describe it in a comment@@dirkstaszak4838 😁

    • @dirkstaszak4838
      @dirkstaszak4838 2 ปีที่แล้ว +4

      I was asked to explain a litte more. I try:
      The data source is a csv, txt or even Excel file. In Step one I do get rid of the headers if there are any.
      Step two is then to determine what columns I want to keep (see below). I generate a list with all columns that do not contain the key word skip. This list is then used.
      Step three is then to rename the columns from that same list.
      I need to import the below table as basis for the above steps
      SpaltenNr NewName Content
      Column1 BuKr Company Code
      Column2 SK Account
      Column3 SKIP Trading Partner
      Column4 PSP PSP-Element
      Code for Step two
      dColPLKeep
      let
      Source = Excel.CurrentWorkbook(){[Name="dColPL_Details"]}[Content],
      #"Changed Type" = Table.TransformColumnTypes(Source,{{"SpaltenNr", type text}, {"NewName", type text}, {"Content", type text}}),
      #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([NewName] "SKIP")),
      SpaltenNr = #"Filtered Rows"[SpaltenNr]
      in
      SpaltenNr
      Code for step three
      dColPL
      let
      Source = Excel.CurrentWorkbook(){[Name="dColPL_Details"]}[Content],
      #"Changed Type" = Table.TransformColumnTypes(Source,{{"SpaltenNr", type text}, {"NewName", type text}, {"Content", type text}}),
      #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([NewName] "SKIP")),
      #"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"SpaltenNr", "NewName"}),
      TransposeTableforList = Table.Transpose(#"Removed Other Columns"),
      Custom1 = Table.ToColumns(TransposeTableforList)
      in
      Custom1
      use of code in main query:
      KeepCol = Table.SelectColumns(RemOldHeading,dColPLKeep,MissingField.Ignore),
      AutoColName = Table.RenameColumns(FltAcc,dColPL,MissingField.Ignore),
      Have fun and of course comments are more than welcome

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว +4

      @@dirkstaszak4838 Wowa, thanks for sharing that. It really shows how you’ve managed to use different Power Query concepts to work for you.
      It’s a bit of code to put in, but if flexibility is what you need, it’s probably worth the effort.
      I appreciate you dropping the example under the video, I’m sure other will appreciate learning about it as much as I do.
      Thanks!🙏

  • @Cap1981
    @Cap1981 ปีที่แล้ว

    Very nice tutorial 👍

  • @hichamhadj9640
    @hichamhadj9640 ปีที่แล้ว

    This is next level. Awesome thanks

  • @FRANKWHITE1996
    @FRANKWHITE1996 2 ปีที่แล้ว

    Well explained. Thanks for sharing.

  • @marcinm.3504
    @marcinm.3504 10 หลายเดือนก่อน

    Thank you. This is very useful and pretty cool solutions👍

  • @yeknafaskesh1257
    @yeknafaskesh1257 2 ปีที่แล้ว

    Excellent video and explanation. Thank you.

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว

      You are welcome!

  • @karimallahwala7022
    @karimallahwala7022 2 ปีที่แล้ว

    Thank you very much.These Tipp are very helpful

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว

      Welcome 😊

  • @VipinThakur
    @VipinThakur 2 ปีที่แล้ว +1

    Issue: What would be the solution if Column name and posting of the column keep changing.
    Ex:
    Column A: Name, Column B: E-mail.
    Next time I get the data in this format
    Column A: E-mail, Column B: Full Name
    This is the big issue I experienced. Do you have any solution for this??

  • @shikuma5
    @shikuma5 2 ปีที่แล้ว

    Hi Rick , I need some help number formatting , i thought you can help me out with it.

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว

      Hi shiv, what exactly are you looking for?

  • @lmsweed
    @lmsweed 2 ปีที่แล้ว +2

    Thank you for this! - which is faster: replacing underscores, or adding spaces inbetween capital and non-capital letters?

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว +1

      My guess would be replacing underscores. It's a bit more complex to check for capital/non-capital!

    • @lmsweed
      @lmsweed 2 ปีที่แล้ว

      @@BIGorilla thank you!

  • @marglego9079
    @marglego9079 ปีที่แล้ว

    Brilliant 👍

  • @aatsw
    @aatsw 2 ปีที่แล้ว

    Superb!

  • @EdDy241907
    @EdDy241907 6 หลายเดือนก่อน

    Great trick!

  • @PedroCabraldaCamara
    @PedroCabraldaCamara ปีที่แล้ว

    Fantastic Rick

  • @asaleem8296
    @asaleem8296 7 หลายเดือนก่อน

    14.45

  • @gauravtiwari3517
    @gauravtiwari3517 ปีที่แล้ว

    Hi sir, I am getting an error :
    We expected a Renameoperations value
    Details: List
    Kindly help

  • @ExcelInstructor
    @ExcelInstructor ปีที่แล้ว

    0:10 lets see if thsi is the method Im using :)

  • @williamrhopkins
    @williamrhopkins 2 ปีที่แล้ว

    Excellent -- I learnt about List.Zip. How about a function that takes a table, takes any of the column formats (CamelCase, Underscores, Spaces) and gives a table with the column names in a canonical format say all words capitalized separated by spaces. I think that is doable.

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว

      You should be able to create a function for that. It can apply three different transformations in a particular order and apply it to the column names. Will you give it a shot Will?

  • @jorstube
    @jorstube 2 ปีที่แล้ว

    Just amazing!!!

    • @BIGorilla
      @BIGorilla  2 ปีที่แล้ว

      Wow wow, thanks for the kind words !! 🚀😁

  • @PranayPawar1991
    @PranayPawar1991 11 หลายเดือนก่อน

    Amazing

  • @titus4415
    @titus4415 2 ปีที่แล้ว

    𝐩𝓻Ỗ𝓂Ø𝓈M 😄

  • @eliasaouad13
    @eliasaouad13 6 หลายเดือนก่อน

    I am using you tutorial and followed the steps. the difference is in data the change column names starts after removing top rows & Promoted Headers steps in Power query. Here is what I have so far: Table.RenameColumns(#"Promoted Headers",List.Zip({Table.ColumnNames(#"Back to Promoted Headers"),#"Transformed Columns"})). I am getting Error: Expression.Error: The name 'Back to Promoted Heaers' wasn't recognized. Make sure it's spelled correctly. It is spelled correctly. I have tried removed the # and the double quotes to no avail. Hope you can help.

  • @williamarthur4801
    @williamarthur4801 2 ปีที่แล้ว

    Great video, really enjoyed playing around with it and using it to promote headers (Goodly) etc.
    One thing I found was if you got your zipped old and new names as a step; you could then just use;
    Table.RenameColumns( Source , newN )
    , wher newM = List.Zip( {zipup [Custom] , zipup[Custom.1] } ),
    One last puzzle, not directly related, is about TEXT.COMBINE, if I use Add custom column i needed
    to convert to text so :
    Text.Combine(
    List.Transform( [Column1] , each Text.From(_) ), " " )) but if i just used the the formula bar
    List.Transform( #"Reordered Columns"[Column1] , (_)=> Text.Combine(_, " " )),
    I no longer needed the Text.From(_) , ?