How to rename columns in Power Query that change the name on each data updating - T0029

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024

Комментарии • 74

  • @GrainneDuggan_Excel
    @GrainneDuggan_Excel 2 года назад +2

    Excellent solution to a problem that pops up in so many scenarios.

  • @wayneedmondson1065
    @wayneedmondson1065 2 года назад +4

    Hi Celia. Great way to start the new year! An awesome and useful lesson. A variation I employed, instead of the List.Select() construct you used to isolate the last 3 column names for the OldNames step, I used List.LastN as follows, = List.LastN(Table.ColumnNames(Base), 3). Assuming you are always after the last 3 column names, then this construct eliminates the need to trap for the old column names with Text.Contains() or the method you used in example 2 by changing the data type and filtering out the errors. Using List.LastN() works for both examples, regardless of the starting column names. List.Zip() is a great find. Thanks for demonstrating and providing the inspiration to learn something new. Looking forward to more in 2022 :)) Thumbs up!!

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  2 года назад +1

      Happy New Year, Wayne!
      Thank you, for your feedback and sharing your solution.
      The idea was to leave the solution the most flexible posible so that more people can use it. The columns to isolate can be in any position, not necessarily at the end of the list.

    • @wayneedmondson1065
      @wayneedmondson1065 2 года назад +1

      @@CeliaAlvesSolveExcel Thanks Celia and good point. List.LastN() works only if trapping for the last column names. Love to know multiple ways to solve. Thanks for your useful examples and solutions! Thumbs up!!

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  2 года назад

      @@wayneedmondson1065 you're very welcome! ;-)

  • @krishanphophalia9303
    @krishanphophalia9303 Год назад +2

    Awesome, Celia 👏👏👏 You have explained so well. 😊

  • @ExcelOffTheGrid
    @ExcelOffTheGrid 2 года назад +2

    Nice solution - it's always exciting to find useful functions in the Power Query documentation :-)

  • @ziggle314
    @ziggle314 2 года назад +1

    Another great post! This is one of the most common problems I encounter. Nice, flexible solution.

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  2 года назад

      Thank you for your feedback! I am glad that you find it helpful.

  • @HachiAdachi
    @HachiAdachi 2 года назад +1

    Thank you for introducing this approach to renaming the columns and to List.Zip function!
    I don't know what the refresh performance difference would be, but my approach involves unpivoting and pivoting back:
    (after the 'Base' step)
    UnpivotedOtherColumns =
    Table.UnpivotOtherColumns(
    Base,
    {"Brand Item", "On Hand", "Allocations", "Available to Promise", "On Order", "PR On Hand"},
    "Attribute", "Value"
    ),
    AddedIndex = Table.AddIndexColumn(UnpivotedOtherColumns, "Index", 0, 1, Int64.Type),
    CalculatedModulo = Table.TransformColumns(AddedIndex, {{"Index", each Number.Mod(_, 3), type number}}),
    ReplacedValues =
    Table.ReplaceValue(
    CalculatedModulo, each [Index], each
    if [Index] = 0 then "Last Week Sale"
    else if [Index] = 1 then "Two Weeks Ago"
    else "Three Weeks Ago",
    Replacer.ReplaceValue,{"Index"}
    ),
    RemovedColumns = Table.RemoveColumns(ReplacedValues,{"Attribute"}),
    PivotedColumn = Table.Pivot(RemovedColumns, List.Distinct(RemovedColumns[Index]), "Index", "Value", List.Sum)
    Most of these steps can be performed with UI except for "ReplacedValues" step. Again, no idea how this performs compared to your solution, but just wanted to share my 2 cents...

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  2 года назад +1

      That's a clever one, Hachi! Thank you for sharing. Not involving a lot of coding is an advantage for many users. It would be interesting to test performance of one method against the other. Thanks!

  • @kebincui
    @kebincui 2 года назад +1

    Thank you very much Celia. Very informative presentation 👍👍🌹🌹

  • @GopiNath-fp5ly
    @GopiNath-fp5ly 2 года назад +1

    You are always giving very nice alternative solutions. Thank you.

  • @mattschoular8844
    @mattschoular8844 Год назад +1

    That was a great example. Thanks Celia

  • @608er
    @608er Год назад +1

    Fantastic!!!!! It took me quite a while to find this answer. Thank you. Great content

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  Год назад

      My pleasure, Ross. Glad that you found it and that it was helpful. 🔥

  • @iankr
    @iankr 2 года назад +1

    Brilliant! Great techniques there - many thanks, Celia.

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  2 года назад +1

      You're welcome, Ian! :) thank you for watching and offering feedback.

  • @goodnewskasparyaodzramedo9097
    @goodnewskasparyaodzramedo9097 Год назад +1

    Thanks. You make power query look easy and interesting

  • @jazzista1967
    @jazzista1967 2 года назад +1

    Celia, this video was very informative: I like the way you dissected the problems into little pieces and troubleshoot the last part of the solution. will practice those 3 functions in M code. Thaks for sharing. Great examples

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  2 года назад

      You're very welcome! Enjoy the exercises. Glad that it was helpful. :) Happy New Year!

    • @jazzista1967
      @jazzista1967 2 года назад +1

      Happy New year to you as well. You really put great (maybe real) examples in your videos. This one appears to be a real-life example from a warehouse or something similar. I use your videos as a reference for data manipulation and overall ETL at work

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  2 года назад

      @@jazzista1967 yes, this example was inspired on a real business case.

  • @kennethstephani692
    @kennethstephani692 2 года назад +1

    Terrific Video!!!!

  • @chahineatallah2636
    @chahineatallah2636 Год назад +1

    Great tips!

  • @FRANKWHITE1996
    @FRANKWHITE1996 Год назад +1

    Very informative. Thanks for sharing ❤

  • @kennethstephani692
    @kennethstephani692 2 года назад +1

    Great video, Celia,

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  2 года назад

      Thank you for watching, Kenneth. I am glad it was useful to you.

  • @user-ez5os8nm2z
    @user-ez5os8nm2z 6 месяцев назад +1

    Excellent

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  6 месяцев назад

      Great! Thank you for watching and leaving your feedback. :)

  • @tlee7028
    @tlee7028 2 года назад +1

    Thank you so much! You’re a life saver …🙏

  • @swarnimajha2848
    @swarnimajha2848 2 года назад +1

    This was very helpful. Thank you :)

  • @JayZ8648
    @JayZ8648 Год назад +1

    Great video very helpful. I have a dumb ? What if you wanted to retain the column names as they are and have them change with the source? Not sure that is even possible. Just wondering as I have a vendor file i pull in every week. Changing the name helped so I can automate but wondering if I'll lose track of the time period

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  Год назад

      Hi, Jay. I am not sure I fully understand your question, but I have the feeling that this video might help: ruclips.net/video/xulaPRyp5EE/видео.htmlsi=bn9sDOSdlnnYA9cj

  • @edwinnugroho5707
    @edwinnugroho5707 6 месяцев назад

    thankyou so muchhhhhhhh for the tutorial

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  6 месяцев назад

      You are very welcommmmme 😄

    • @edwinnugroho5707
      @edwinnugroho5707 6 месяцев назад +1

      hi Celia@@CeliaAlvesSolveExcel , how about if we have dynamic file name? in case the file needs to have a date and I'm Get Data from Excel Workbook, do you have any solution?

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  6 месяцев назад

      Hi, Edwin. This lesson might have what your need.
      ruclips.net/user/livecUyx7CuXqQc?si=_5Tl6oylHqkAd1lm
      If the data is in OneDrive or SharePoint, there's more to it.

  • @lionels839
    @lionels839 Год назад

    Another option is to relate the rename table (with old and new names) to the data table (with old names) in the data model if the new names are used in pivot tables

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  Год назад

      I didn't test this, but I don't think it would work. Relationships in the data model allow you to relate columns and cross information between items values existing in columns of different tables.
      The table with old and new names refer to the column headers - not the item values belonging to one column.

    • @lionels839
      @lionels839 Год назад +1

      Hello Célia
      If you unpivot, your headers will belong to one column and it works. In my case my source don’t change but I just want to be able to display new names When needed

    • @lionels839
      @lionels839 Год назад +1

      Celia you were absolutely right. It does not work (the results were wrong).
      My problem is that my headers are unpivoted in one column So I need to rename rows because if I pivot the process is so slow (hundred of thousands of rows)

  • @Soulenergy31
    @Soulenergy31 2 года назад +1

    Beatiful

  • @VipinThakur
    @VipinThakur 2 года назад +1

    Thanks for sharing. It is amazing. You explained it very well.
    I have another issue hope you can help.
    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 following format
    Column A: E-mail, Column B: Full Name
    This is the big issue I experienced. Do you have any solution for this

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  2 года назад

      Hi, Vipin. Please check this other video and see if it helps: ruclips.net/video/xulaPRyp5EE/видео.html

  • @alanbotten357
    @alanbotten357 2 года назад

    I have to change two months in the same Sheet Jan and Feb, How do I create Oldname and Newname for both with the List.Select function. If i do both separately the end result is not correct?

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  2 года назад

      What are the old names you have, and which new names you want to replace the old names?

    • @alanbotten357
      @alanbotten357 2 года назад

      @@CeliaAlvesSolveExcel The old names are Jan and Feb and I want to replace these with MTD - Thank you!

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  2 года назад

      @@alanbotten357 do you want to rename Jan as MTD and Feb as MTD as well?

    • @alanbotten357
      @alanbotten357 2 года назад

      @@CeliaAlvesSolveExcel Yes

    • @alanbotten357
      @alanbotten357 2 года назад

      @@CeliaAlvesSolveExcel Jan and Feb are part of a Heading e,g. Net PCR Actual for Agy REM Feb 2022 mtd , and, Validation Required at Jan 2022

  • @-Tharos-
    @-Tharos- Год назад +1

    Do I hear a Portuguese accent? 🙂

    • @CeliaAlvesSolveExcel
      @CeliaAlvesSolveExcel  Год назад

      Yes. I can't hide it, he? (The "he" is Canadian.) 😁

    • @-Tharos-
      @-Tharos- Год назад

      @@CeliaAlvesSolveExcel Easy to spot, watching the video from the other side of the Atlantic. 🙂 This tutorial is great stuff BTW. Thanks.