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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not 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

CAM1/21/2020Africa Large
CAM6/10/2020 Modern 
CAM10/3/2020  Large
ABC1/3/2020North AmericaModern 
ABC3/15/2020  Small
ABC7/7/2020 ModernSmall
DON2/7/2020   
DON3/24/2020AsiaClassic 
DON4/23/2020  Small
DON5/15/2020   

 

With the desired output requiring FillUp + FillDown by Project Name

Project NameDateRegionStyleSize
CAM1/21/2020AfricaModernLarge
CAM6/10/2020AfricaModernLarge
CAM10/3/2020AfricaModernLarge
ABC1/3/2020North AmericaModernSmall
ABC3/15/2020North AmericaModernSmall
ABC7/7/2020North AmericaModernSmall
DON2/7/2020AsiaClassicSmall
DON3/24/2020AsiaClassicSmall
DON4/23/2020AsiaClassicSmall
DON5/15/2020AsiaClassicSmall

 

I've manged to source a grouped rows formula that allows for one fill action in a single table column:

 

#"Grouped Rows" = Table.Group(#"Changed Type", {"Project Name"}, {{"Project Name.1", each Table.FillDown(_,{"Region"}), type table [Project Name=text, Date=datetime, Region=text, Style=text, Size=text]}})

 

And would like to check if how to expand this to multiple columns and fill in both directions as well.

 

Other solutions also welcomed.

 

Thank you.

1 ACCEPTED SOLUTION
shaowu459
Resolver II
Resolver II

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"}))

1.png

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks for the solutions @PhilipTreacy  and @shaowu459 

 

I checked that they both work for the sample data set I've given, and I apologise for for giving a poor sample, but @shaowu459 's solution is the ideal one when combined with Group by Rows (Replaced "Source" with "_") + Expanded Rows (see below).

The reason being if any of the columns are all null for a single Project (should have left one part blank in the initial request), then it wouldn't have been filled down with data from other Projects.

 


let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Grouped Rows" = Table.Group(Source, {"Project Name"}, {{"Project Name.1", each Table.ReverseRows(Table.FillDown(Table.ReverseRows(Table.FillDown( _ ,{"Region","Style","Size"})),{"Region","Style","Size"})), type table [Project Name=text, Date=datetime, Region=text, Style=text, Size=text]}}),
#"Expanded Project Name.1" = Table.ExpandTableColumn(#"Grouped Rows", "Project Name.1", {"Date", "Region", "Style", "Size"}, {"Date", "Region", "Style", "Size"}),
in
#"Expanded Project Name.1"

 

So thanks very much for the guidance!!

Glad we could help😋

shaowu459
Resolver II
Resolver II

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"}))

1.png

PhilipTreacy
Super User
Super 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.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.