Dynamically add missing columns in Power Query

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

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

  • @jaimeildefonsosegurapena7328
    @jaimeildefonsosegurapena7328 3 года назад +17

    Ruth...
    You can just use the pattern as the step and you'll get the corrected table in a single step.. as it will create the table (no need to keep 1st row, other columns remove and further expand)...
    To do so just press the "fx" and type the pattern:
    = if Table.HasColumns( Source ,"Country code" ) then Source else
    Table.Combine( {Source, Table.FromRows ({ }, {"Telephone", "Country code"}) } )

    • @CurbalEN
      @CurbalEN  3 года назад

      Fabulous! Why didnt I think of that? Thanks a million :)))

    • @jaimeildefonsosegurapena7328
      @jaimeildefonsosegurapena7328 3 года назад +1

      @@CurbalEN I once had a similar problem... and had to figured out my self... Where did you find the pattern as it will be useful to have a help source for checking next time?

    • @CurbalEN
      @CurbalEN  3 года назад +2

      The link is in the description box :)

  • @HowToExcelBlog
    @HowToExcelBlog 3 года назад +2

    What I've done a few times is create an empty table with the complete set of columns, then append my data to the empty table. Any missing columns are added by the append!

    • @CurbalEN
      @CurbalEN  3 года назад +1

      Yes, thatbis also an option:)

  • @sebastiendebosscher
    @sebastiendebosscher 3 года назад +1

    Hi Ruth, I suggest this one step solution:
    Table.Combine({Source, #table({"Name", "Surname", "Phone", "Country code"}, {})})

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

    Nice one Ruth
    I used the option "Insert step after " in the query editor and added the following code instead of adding as a custom column which helped to avoid the removing columns and removing rows steps.
    = if Table.HasColumns( #previousstep,{"Address","Name"}) then #previousstep
    else Table.Combine({#previousstep,Table.FromRows({},{"Address","Name"})})

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

      This is much cleaner, and it works well. I can list all the columns that need to be there, and list them all in the needed, rather than having several steps to check each column.

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

    Hi, i have one question. If there are multiple sheets and some sheets has one particular column less than other sheets. Upon loading in power query it shows error, as all sheets doesn't have equal columns. Any way where we can add that missing column on the missing sheet so that upon loading it doesn't gives error?

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

    So if my web data table has more or less columns, it will amend that automatically?

  • @ahmedal-dossary4386
    @ahmedal-dossary4386 3 года назад +1

    OMG!
    That’s amazing, thanks for sharing this trick!

  • @athome9712
    @athome9712 11 месяцев назад

    Thank you so very much for this tutorial. I actually found this code in my searches, but was stuck once I had the new column with the tables. Your extra steps got me to the finish line.

  • @KenLoewen
    @KenLoewen 3 года назад

    Ruth - this is amazing! Thank you so very much for sharing and, Jaime Ildefonso SEGURA PENA, thank you also for the great enhancement to the technique.

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

    What if I want to remove certain columns from the source tables ?
    This seem to work when you want to add new...not the other way around

  • @silverfunnel6819
    @silverfunnel6819 3 года назад

    Hello, I have a question about conditional columns. Would it be possible to select a column and position the custom column after that column and not at the end? Or is it usual practice to drag it to the right position after having created it? I like your channel:-)

  • @vida1719
    @vida1719 3 года назад

    This is very useful in scenarios where number of columns can differ from original table

  • @johnzafe
    @johnzafe 3 года назад

    Hi! This really helpful! Thank you thank you thank you thank you thank you so much!!!!!!

  • @sdtspv-ruhulaminkhan5211
    @sdtspv-ruhulaminkhan5211 3 года назад

    Your body language is good

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

    I appreciate your excellent video and tutorial very much. They provided me with the exact solution I needed for a long time. You have saved me a lot of time and effort in my work. Thank you for your valuable contribution.

  • @Sreekanth69akula
    @Sreekanth69akula 3 года назад

    I have developed power BI report using Power BI report using Power BI desktop free version. I have done conditional formatting in the report where in I need to apply colors for some fields in the report. I have published the reports in the power BI service.
    Now after publishing in the power BI service, I need to export this report into Excel format. I am not getting option to export this report as excel, but getting option to export it as CSV file. I am not able to see coloured field in CSV file.
    Could you please help me how to resolve this issue? Do I need to build this report as paginated reports? Then only I would get option to this file as excel and I can see the colors in excel file? Please suggest

    • @CurbalEN
      @CurbalEN  3 года назад

      Use analyze in excel instead. You will have to rebuild the report again in excel, but it should work after that.

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

    the relief in your face lol, look you were struggling like I am with some tables hopefully your solution will work for me as well, thanks for sharing!

  • @nboisen
    @nboisen 3 года назад

    Excellent! Now the trick would be to convert this into a function and include ALL the rows of your original source table and ALWAYS include it by default when working with merging multiple source files, since you never know when you will run into this issue along the line.

  • @EricaDyson
    @EricaDyson 3 года назад

    This happened to me only the other day.. suddenly columns disappeared in the source data and messed up my queries. Now I know what to do! Thanks

    • @CurbalEN
      @CurbalEN  3 года назад

      Use the pattern as a step to avoid the tables!

  • @RobertoStaltari
    @RobertoStaltari 3 года назад

    M is magic! Thanks Ruth

  • @andredeoliveira3684
    @andredeoliveira3684 3 года назад

    Great job! I always watch your videos

    • @CurbalEN
      @CurbalEN  3 года назад

      Thanks for the support!

  • @paspuggie48
    @paspuggie48 3 года назад

    Another cracking tip Ruth 😂🙂😄

    • @CurbalEN
      @CurbalEN  3 года назад

      I mossed the mark with this one, it should be used as a new step not a add column 🙈🙈🙈
      Live and learn...

  • @felipelandim2881
    @felipelandim2881 3 года назад

    Nice!

  • @jaymehta3320
    @jaymehta3320 3 года назад

    Super!!

  • @abhishekstatus_7
    @abhishekstatus_7 3 года назад

    Thanks for sharing this Ruth !! Have a great week ahead!!

  • @KapilBisht88
    @KapilBisht88 3 года назад

    Thanks for sharing!👍

    • @CurbalEN
      @CurbalEN  3 года назад +1

      My pleasure :)