Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Conditional Fill Down (Base on a Column)

Hello everyone,   I'm in need to conditionally fill down a column base on another column within the table. I currently have a table with the format somewhat like below:   After doing some c...
  • latimeria's avatar
    3 years ago

    Hi Anonymous ,

     

    Try this:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZdDBCoAgDAbgd9nZQ1KQHZNidAvdJcT3f42cNpolMuHzd4opgQUDq4+llhkgmwRVsNRx4MFbwvEJVphYEJvEPmM/ByVWYWY5iGOLvsFVv9hdY5IGeyDFooFItbW85XGTvmU9JamsZe3vVRqoF/d+RL4B", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Cust#" = _t, #"Cust Name" = _t, Limit = _t, Terms = _t]),
        #"Replaced Value" = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"Cust#", "Cust Name", "Limit", "Terms"}),
        #"Filled Down" = Table.FillDown(#"Replaced Value",{"Cust#"}),
        #"Grouped Rows" = Table.Group(#"Filled Down", {"Cust#"}, {{"Rows", each _, type table [#"Cust#"=nullable text, Cust Name=nullable text, Limit=nullable text, Terms=nullable text]}}),
        #"Fill Down" = Table.TransformColumns(
            #"Grouped Rows", 
            {
                {"Rows", each Table.FillDown(_, {"Limit"})}
            }
        ),
        #"Fill Up" = Table.TransformColumns(
            #"Fill Down", 
            {
                {"Rows", each Table.FillUp(_, {"Limit"})}
            }
        ),
        Expanded = Table.Combine(#"Fill Up"[Rows])
    in
        Expanded