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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
SNB
New Member

How to fill in blanks in one column with the previous raw value from another column

Hello all, I need help, pleaseee...
Is there a way in Power Query to fill in blanks in one column with the previous raw value from another column? Please see example below. Thank you all!

Example Screenshot.png

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

=Table.Combine(Table.Group(YourTable,"Rank",{"n",each Table.ReplaceValue(_,null,(x)=>[Institution]{0},Replacer.ReplaceValue,{"Rank"})},0,(x,y)=>Byte.From(y<>null))[n])

View solution in original post

7 REPLIES 7
wdx223_Daniel
Super User
Super User

=Table.Combine(Table.Group(YourTable,"Rank",{"n",each Table.ReplaceValue(_,null,(x)=>[Institution]{0},Replacer.ReplaceValue,{"Rank"})},0,(x,y)=>Byte.From(y<>null))[n])

Anonymous
Not applicable

Hi @SNB ,

 

Please try this:

let
    Source = Table.FromRecords({
        [Rank = 1, Institution = "AA"],
        [Rank = null, Institution = "BB"],
        [Rank = null, Institution = "CC"],
        [Rank = null, Institution = "DD"],
        [Rank = 2, Institution = "EE"],
        [Rank = null, Institution = "FF"],
        [Rank = null, Institution = "GG"]
    }),
    AddIndex = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
    Custom1 = Table.FromRecords(Table.TransformRows(AddIndex, (x)=> if x[Rank] = null then [Rank=AddIndex[Institution]{x[Index]-1},Institution=x[Institution],Index=x[Index]]  else x))
in
    Custom1

Please consider lbendlin's suggestion to try to add Index columns in the data source

vcgaomsft_0-1728964712881.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Unfortunately, my list of institutions is too long, I will not be able to manually rank each. And I need for all the blanks to be equal to the same value. In your example, for Rank 1, it is AA, for Rank 2 it is EE, etc. Thank you for looking into that though!

Omid_Motamedise
Super User
Super User

Add a custome column based on the next formula.

 

if [Rank]=null then null else [Institution]

 

 

then use fill down command (from transfrom tab) for this new column.


If this answer helped resolve your issue, please consider marking it as the accepted answer. And if you found my response helpful, I'd appreciate it if you could give me kudos. Thank you!

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h

Thank you for advice, but this will not do what I need 😞

Which part of the result is different?

It can do what you explained on the question by adding a new column, then you can remove the last column in more efficient way. using index collumn and refering to the previous step is really time consuming.

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
lbendlin
Super User
Super User

Power Query has no idea what you mean by "Previous".  Bring your own index column (starting from 0) and then use that to address the prior row's content.

 

Ideally that index column should come from the source data as Power Query gives no sorting guarantee.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors