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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Fill in blanks based on previous records

 

I would like to fill the city column based on the zip column. See sample below

 

city.JPG

5 REPLIES 5
v-jingzhang
Community Support
Community Support

@Anonymous 

Select the columns with blank value, replace blank value with null, then select these columns again and use Fill Down.

v-jingzhang_0-1601360711464.jpeg

 

Community Support Team _ Jing Zhang

If this post helps, please consider Accept it as the solution to help other members find it.

FrankAT
Community Champion
Community Champion

Hi @Anonymous 

you can do it very easy with Power Query like this:

// Table
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCihKLckvykxU0lFyTywtSc1LB7IMTY2AZHB+aUkGkHZMK8pMTlSK1YlWIk6VT2pBRmJOYk4qUNgnM7cgvyAfyDI1NcVpKD5p7C40MiZBtZExDpdiVW1sZEiK2YbYzI4FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [City = _t, State = _t, Zip = _t, Country = _t, #"(blank)" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"City", type text}, {"State", type text}, {"Zip", Int64.Type}, {"Country", type text}, {"(blank)", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","",null,Replacer.ReplaceValue,{"City", "State"}),
    #"Filled Down" = Table.FillDown(#"Replaced Value",{"City", "State"})
in
    #"Filled Down"

24-09-_2020_22-21-04.png

 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

Anonymous
Not applicable

Hi @FrankAT 

 

do you mind sharing the file on which you have worked?

Fowmy
Super User
Super User

@Anonymous 

Not very clear about how you want to fill the blank, can you show the expected results. 

Power Query offers a function to Fill Down.

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

From the example, The second entry in 'city' is empty, however the previous record for the 'zip' 152, the city is Pretoria. Therefore I would like  a strategy to check if city is empty for certain zip, then the city should be the city for when that zip code was not blank. 

 

see desired result below;

city 2.JPG

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.