Insert Blank Row for each change in a value using Power Query

Поделиться
HTML-код
  • Опубликовано: 5 авг 2024
  • Power Query in Excel can be used for so many purposes and converting data ready for upload into another system is just one.
    In this scenario I show a couple of techniques to insert a row for each change in a group of items.
    Did you know a Query can be appended with itself!?
    00:00 Intro
    00:38 Setting the Scenario
    02:14 The Steps
    03:56 Appending a query with itself and change a table name to a step name
    05:15 Conditional Column
    06:48 Alternative approach to adding a conditional column
    08:53 Testing with extra data
    09:30 Recommended extra elements - renaming and adding comments
    Follow me on LinkedIn
    / wynhopkins
    Twitter
    / wynhopkins
    Access Analytic Training
    accessanalytic.com.au/training
  • ХоббиХобби

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

  • @larsbengtsson3216
    @larsbengtsson3216 5 дней назад +1

    Thanks! You saved my day! (and a lot of days ahead!)

    • @AccessAnalytic
      @AccessAnalytic  5 дней назад

      You’re welcome. I appreciate you taking the time to let me know you found it useful

  • @mandypaulissen
    @mandypaulissen 8 месяцев назад +3

    It's insanely nerdy, but more importantly it's insanely brilliant!!!!!! It save a lot of precious life time!!

  •  Год назад +1

    Outstanding! Excellent description of the thinking process to imagine the solution and progress to implementation.

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

    Love it. So many tips packed in a few minutes

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

    that's the advanced techniques that we need more of!!!, I consider myself an advanced user of power query and I just learned from you something new. Thanks a ton :)

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

      We’re all learning Azzam, glad to help, thanks for taking the time to let me know it’s useful.

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

    Thank you so much! Huge thank you man! I performed this process at work manually and it took me a lot of time to do it, now everything is automated. Health and good luck, thanks again! :) You are a really cool professional

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

    Thanks a lot! The extra row and "append query" helped me in making a total row per "Journal" as it were. Very good video's!!

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

      Thanks for letting me know. Glad I could help

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

    A few years ago I barely played Power Query. Now, among other reasons, by watching your videos, I have become a fan of Power Query. Thank you Wyn!!

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

    Love the data wrangling tips! Thanks

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

      Great! Thanks for letting me know Andrew

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

    Fab just what I needed!

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

    WYN, you won our hearts ♥️♥️♥️

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

    Incredibly useful. Thank you very much!

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

    Like always your explanations are very clear !!!

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

    Hi Wyn. Awesome! Nice to understand two ways to solve it. Thanks for sharing :)) Thumbs up!!

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

      Cheers Wayne. Always more than 1 way to tackle these things

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

    Fabulous!👍🌹🌹Thanks Wyn for sharing

  • @rick_.
    @rick_. 2 года назад +1

    I always learn something from your videos!

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

    I love the way you think Wyn - great idea

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

    This is brilliant! Thank you.

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

    Thank you so much, very usefull and well explained :)

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

    You are amazing , im still a beginner in Power Query , but im learning so much from you

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

      Glad to help you along your learning journey

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

    Wow! You are a gem!!!

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

    This is great! Thank you Wyn!

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

      Thanks Alejandra 😀. Good work on your new video too

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

      @@AccessAnalytic Thank you so much!! 😊

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

    Amazing solution, thank you!

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

    This is so so clever!

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

    Thanks, nicely explained

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

    Very nice method. I like your 2nd method.

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

      Thanks, I'll be doing a video on a 3rd method several people submitted

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

      @@AccessAnalytic Would like to see the third method too.

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

      @@Bhavik_Khatri just published it

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

    Pretty usefull !and i LOVE your english accent !

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

      Thanks, it's half Australian Half Welsh 😆

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

    Very good- some useful tricks in there :)

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

      Cheers Martin, thanks for letting me know

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

    Well explained

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

    very impressive!

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

    Very useful

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

    Brilliant

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

    We can also add an index column in the beginning as the "Journal" column in the video and remove it at the end. In this way, we won't hardcode any header names.
    Here is the M code. Thanks again for the inspiring video.
    let
    Source = Excel.CurrentWorkbook(){[Name="example"]}[Content],
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 1, 1, Int64.Type),
    OriginalData = #"Added Index",
    #"Removed Other Columns" = Table.SelectColumns(OriginalData,{"Index"}),
    #"Appended Query" = Table.Combine({#"Removed Other Columns", OriginalData}),
    #"Sorted Rows" = Table.Sort(#"Appended Query",{{"Index", Order.Ascending}}),
    #"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Index"}),
    #"Removed Top Rows" = Table.Skip(#"Removed Columns",1)
    in
    #"Removed Top Rows"

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

      Thanks Isaiah, that's a nice solution if we want a blank row after every single entry.

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

      Yes, I noticed that right after sending out the post and don't know how to withdraw the post 😆.
      Sorry for my ignorance. 😅
      Again, I have seen how to insert blank rows before, but your method is simplest and with least hardcoding. Nice work! Thank you for sharing the idea.

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

      @@IsaiahHuang - all suggestions are welcome :). Thanks for following the channel

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

    nice this inspired me for one i i was looking at that needed 2 blank rows. For the blank row table i created a custom column with "1,2" called it decimal. Then did a split column by delimiter but split to rows then converted to number and multiplied by .1. I then added a normal index and column. Using math I combined the index column + the decimal column. and got rows like 1.1, 1.2, 2.1, 2.2, 3.1, 3.2 ..... then on my main table I created an index, Appended the new table and sorted. So the main Index was 1 with the blanks being 1.1, 1.2. then next group 2, 2.1, 2.2...
    then it all sorted nice.
    was surprised it worked so nicely.

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

    Thank you for sharing! from your example, how would I remove repeated J1-23? I would only like to keep say... J1-23 and J1-24. thanks !

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

      Difficult to explain without screen but I'm thinking add an INDEX Column, create a reference step that then picks the Journal column and the index column. Remove duplicates on the Journal column. Merge back with the query prior to the reference step and expand. That probably makes no sense! 😆

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

    Thanks for this tutorial - can you change it to add the blank row above each change and use the Journal number in the added row (so that it looks like a sub header) do you have a tutorial on that please ?

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

      There’s probably a way using the opposite sort order to get the row at the top. Then some form of Add Column - Conditional column to get the label

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

    Thanks! Could you calculate turn around time where after 3 pm it is consider as next day if it is weekend or Holiday then we have to exclude those days as well.

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

      Yes that sort of thing is possible using Custom columns containing “if” functions

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

    💯👍

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

    Thank you so much for the explaining ,,,,, Ok...I got it ....But now I would like to put 4 row between ,, how I can do that :

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

    How would you add multiple rows for each change in value? For example, I have a table of departments and project codes and I wanted to add a few new project codes for each department.

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

      Not sure I understand the use case, but to add 2 rows where I added one you could in theory do an extra combine of the BlankRowHelper step

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

    great....and how can I add 4 row instead one between repited dates

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

      Add a custom column to the Helper rows part containing ={1..4} then expand to rows

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

    Great video. I followed every step and I was able to get my query with the blank rows between sets of data. However, when I loaded the query to my sheet, it shows the blank rows at the bottom. Do you have any idea what can the problem be?

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

      Is there a sort on one of your table columns? Click On the excel table, go to data and click the clear filters icon then refresh

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

      @@AccessAnalytic Thanks for your reply. There isn't any sorting, I even tried removing the filters.

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

      Very odd - add an index column to your last power query step and then load that to see what happens

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

    Insert Blank Row for each change in a value. How about . . .
    Alt+F11 (opens VBA) - Insert Module - paste the following:
    Sub InsertRowsAtValueChange()
    'Update 20140716
    Dim Rng As Range
    Dim WorkRng As Range
    On Error Resume Next
    xTitleId = "KutoolsforExcel"
    Set WorkRng = Application.Selection
    Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
    Application.ScreenUpdating = False
    For i = WorkRng.Rows.Count To 2 Step -1
    If WorkRng.Cells(i, 1).Value WorkRng.Cells(i - 1, 1).Value Then
    WorkRng.Cells(i, 1).EntireRow.Insert
    End If
    Next
    Application.ScreenUpdating = True
    End Sub
    Run macro highlighting the column where the data changes (eg Date or Time)

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

      Yep a huge amount of Power Query can be replicated in VBA. Cheers Michael.