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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
JoelDucharme
Helper I
Helper I

Delete rows for some columns to align the data

I have a table, extracted from Sage50 to Excel.

The data is unfortunately not alligned correctly. I need to delete the first row for the last 5 columns. Is there a way to do this?

Thanks.

JoelDucharme_0-1734453157786.png

 

1 ACCEPTED SOLUTION

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("nc9BCsMgFEXRvTh28t9bQdroJiQ7CJ11/613GD4BM7mCPNAzRomt1BKvfz7f88yPo47LdbxjdqeN9kh3Ykcb7Up3Zkcb7U5293/UtGjVIizCIixKLcIiLMKi1CIswiIsemDxtHjVYizGYixOLcZiLMbi1HLz9vED", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column A" = _t, #"Column B" = _t, #"Column C" = _t, #"Column D" = _t, #"Column E" = _t, #"Column F" = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,"null",null,Replacer.ReplaceValue,{"Column A","Column B","Column C","Column D","Column E","Column F"}),
    #"Filled Down" = Table.FillDown(#"Replaced Value",{"Column A", "Column B"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Column C] <> null))
in
    #"Filtered Rows"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the entire Source step with your own source.

View solution in original post

8 REPLIES 8
JoelDucharme
Helper I
Helper I

Sorry about that. Still learning. I hope the following will be better to help.

So here is an example of what I have. 

Column AColumn BColumn CColumn DColumn EColumn F
1A1Bnullnullnullnull
nullnull1C11D11E11F1
nullnull1C21D21E21F2
nullnull1C31D31E31F3
nullnullnullnullnullnull
2A2Bnullnullnullnull
nullnull2C12D12E12F1
nullnull2C22D22E22F2
nullnull2C32D32E32F3
nullnullnullnullnullnull
3A3Bnullnullnullnull
nullnull3C13D13E13F1
nullnull3C23D23E23F2
nullnullnullnullnullnull

By deleting the first row of Columns C to F, everything will be aligned. 

 

This is what I need the data to look like in the end, after realigning things, deleting empty rows and fill down for Columns A and B.

Column AColumn BColumn CColumn DColumn EColumn F
1A1B1C11D11E11F1
1A1B1C21D21E21F2
1A1B1C31D31E31F3
2A2B2C12D12E12F1
2A2B2C22D22E22F2
2A2B2C32D32E32F3
3A3B3C13D13E13F1
3A3B3C23D23E23F2

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("nc9BCsMgFEXRvTh28t9bQdroJiQ7CJ11/613GD4BM7mCPNAzRomt1BKvfz7f88yPo47LdbxjdqeN9kh3Ykcb7Up3Zkcb7U5293/UtGjVIizCIixKLcIiLMKi1CIswiIsemDxtHjVYizGYixOLcZiLMbi1HLz9vED", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column A" = _t, #"Column B" = _t, #"Column C" = _t, #"Column D" = _t, #"Column E" = _t, #"Column F" = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,"null",null,Replacer.ReplaceValue,{"Column A","Column B","Column C","Column D","Column E","Column F"}),
    #"Filled Down" = Table.FillDown(#"Replaced Value",{"Column A", "Column B"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Column C] <> null))
in
    #"Filtered Rows"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the entire Source step with your own source.

Thanks.

I'm sorry but I didn't think about the column types with the sample data.

I noticed in the code that there is a column type as text. Would this change something? I tried it with the sample data and it works, but not with the different column types. 

 

This is more how it would look. 

Account Number (number)Account Description (text)Date (Date)Description (Text)N°ÉJ (Text)Montant (Dollar)
55741Bnullnullnullnull
nullnull2024-01-02Description 11E1          10,00  $
nullnull2024-01-06Description 21E2        263,00  $
nullnull2024-09-08Description 31E3        235,67  $
nullnullnullnullnull null 
55782Bnullnullnull null 
nullnull2024-10-03Description 42E1        345,68  $
nullnull2024-11-07Description 52E2 234.65 
nullnullnullnullnull null 
56983Bnullnullnull null 
nullnull2024-02-05Description 63E1  34 554,55  $
nullnull2024-03-07Description 73E2        453,00  $
nullnullnullnullnull null 
56794Bnullnullnull null 
nullnull2024-01-07Description 84E1    6 624,40  $
nullnull2024-02-26Description 94E2    8 456,30  $
nullnull2024-11-15Description 104E3  56 798,00  $

Not really - the process is the same.  Fill down the first two columns. Then filter out the nulls in the third column.

I think it worked! Thank you very much! I really have to take the time to learn Dax better.

JoelDucharme
Helper I
Helper I

Sorry, i don't get how if I fill up or down it will align my columns. If I fill up the last 5 columns, I will only get duplicates of everything. If I fill down the first 2 columns, I will get a whole bunch of unwanted rows.

 

I need to delete the first rows of the last 5 columns so that after I can delete all the empty rows and then I will fill down to ensure that all the info is there.

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

lbendlin
Super User
Super User

Read about Fill Up/Fill Down.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.