Forum Discussion
Anonymous
5 years agoNot applicable
Group by Rows then FillUp & FillDown for multiple columns
Hello, I'm trying to clean data on a project database where incremental information is added over time: Project NameDateRegionStyleSize CAM 1/21/2020 Africa Large CAM 6/10/2020 ...
- 5 years ago
Hi Anonymous , try this. Source is the table you upload to PQ editor.
= Table.ReverseRows(Table.FillDown(Table.ReverseRows(Table.FillDown(Source,{"Region","Style","Size"})),{"Region","Style","Size"}))
PhilipTreacy
5 years agoSuper User
Hi Anonymous
You can do this by sorting columns, making sure that the text you want to fill down is always at the top of the relevant column, whilst maintaining sorting on your Project Name column.
Here's a sample PBIX file and the query.
NOTE: If your columns contain empty strings "" then you need to replace them with null for this to work. That's what I've done in the 3rd step of the query.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcnb0VdJRMtQ3AiIDIwMg2zGtKDM5EcgAIp/EovRUpVgdmDozfUMDmDog8s1PSS3KA7ERSoAKjJGUoBji6OQMtgyuwC+/qCRDwTE3FWolqoEQ5cb6hqaoBgbnJubkIKkw1zfH5iiEMhd/PyDfCEUZzBKIHNBFJvAAKM4EucU5J7G4ODMZVR1QkTEux0BUmGI4Vyk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project Name" = _t, Date = _t, Region = _t, Style = _t, Size = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Project Name", type text}, {"Date", type text}, {"Region", type text}, {"Style", type text}, {"Size", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","",null,Replacer.ReplaceValue,{"Region", "Style", "Size"}),
#"Sorted Rows" = Table.Sort(#"Replaced Value",{{"Project Name", Order.Ascending}, {"Region", Order.Descending}}),
#"Filled Down" = Table.FillDown(#"Sorted Rows",{"Region", "Style"}),
#"Sorted Rows1" = Table.Sort(#"Filled Down",{{"Region", Order.Ascending}, {"Size", Order.Descending}}),
#"Filled Down1" = Table.FillDown(#"Sorted Rows1",{"Size"})
in
#"Filled Down1"
Phil
If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.