Skip to content

Power Apps

Fill Blanks In A Column With Last Non-Blank Value

Fill Blanks In A Column With Last Non-Blank Value Input collection: myCities52 Country City Population United States New York 8600000 Los Angeles 4057000 Chi...

Matthew Devaney
Published
Reading time
1 min read

Before you start

Is this guide for you?

Best entry point
Power Apps
Time investment
1 min read

Imported reference from Matthew Devaney's blog for learning purposes. Original: https://www.matthewdevaney.com/powerapps-collections-cookbook/fill-blanks-in-a-column-with-last-non-blank-value/. Author: Matthew Devaney.

Fill Blanks In A Column With Last Non-Blank Value Input collection: myCities52 Country City Population United States New York 8600000 Los Angeles 4057000 Chicago 2679044 Canada Toronto 5429000 Montreal 3519000 Mexico Mexico City 8000000 Output collection: mySolution52 Country City Population United States New York 8600000 United States Los Angeles 4057000 United States Chicago 2679044 Canada Toronto 5429000 Canada Montreal 3519000 Mexico Mexico City 8000000 Solution code: //Create a collection

ClearCollect( myCities52, { Country : "United States" , City : "New York" , Population : 8600000 }, { Country : Blank(), City : "Los Angeles" , Population : 4057000 }, { Country : Blank(), City : "Chicago" , Population : 2679044 }, { Country : "Canada" , City : "Toronto" , Population : 5429000 }, { Country : Blank(), City : "Montreal" , Population : 3519000 }, { Country : "Mexico" , City : "Mexico City" , Population : 8000000 } );

//Fill cells with last non-blank value code

ClearCollect(fillBlanksWith,{ Country : "" });

ClearCollect(mySolution52,myCities52); ForAll( myCities52, If(IsBlank(myCities52[@Country]), Patch( mySolution52, LookUp(mySolution52,City=myCities52[@City]), { Country : First(fillBlanksWith).Country} ), Patch( fillBlanksWith, First(fillBlanksWith), { Country : myCities52[@Country]} ) ) ); Code language: JavaScript ( javascript )

Share this

Tagged

Power Apps

Have a Microsoft 365 topic idea?

Share article suggestions, community session ideas, corrections, or real-world scenarios for future nextM365 learning notes.

Suggest a topic

Keep learning Microsoft 365

Explore more practical guides for SharePoint, Power Platform, Copilot Studio, migration, automation, governance, and security.

Continue learning

Next action

What to do next

Browse all tutorials →