Forum Discussion

mohanpal's avatar
mohanpal
Frequent Visitor
4 years ago
Solved

Fill rows in a column based on filter

Hi,

 

I want to fill all the rows in a new column based on filteritng different column.

 

Sample data:

 

New Col should fill all the rows with whatever the value is at Index = 1

 

 

 

  • Hi! mohanpal 

     

    You can use the function fill down in query editor.

     

    Select the column and use the fill down option.

     

     

     

     

3 Replies

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Most Valuable Professional

    See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjEyUNJRMlSK1YGxjSBsYyMg2xiJbQJhm5oC2aYQtoUZkG0GZVsC2eZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Col A" = _t, Index = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Col A", Int64.Type}, {"Index", Int64.Type}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "New Col", each if [Index]=1 then [Col A] else null, type number),
        #"Filled Down" = Table.FillDown(#"Added Custom",{"New Col"})
    in
        #"Filled Down"

     -------------------------------------------------------------------------------------------------------

    👍 It's been a pleasure to help you | Help Hours: 11 AM to 9 PM (UTC+05:30)

    How to get your questions answered quickly -- How to provide sample data

    -------------------------------------------------------------------------------------------------------

  • Hi! mohanpal 

     

    You can use the function fill down in query editor.

     

    Select the column and use the fill down option.

     

     

     

     

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion

    NewStep=let val=PreviousStepName{[Index=1]}?[ColA]? in Table.AddColumn(PreviousStepName,"NewCol",each val)