Forum Discussion
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_VermaMost 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
-------------------------------------------------------------------------------------------------------
- AnkitKukrejaSuper User
Hi! mohanpal
You can use the function fill down in query editor.
Select the column and use the fill down option.
- wdx223_DanielCommunity Champion
NewStep=let val=PreviousStepName{[Index=1]}?[ColA]? in Table.AddColumn(PreviousStepName,"NewCol",each val)