Unfill in Multiple Columns - Excel, Power Query and Python in Excel
- V E Meganathan
- 21 hours ago
- 1 min read
Remove repeated consecutive values in Qtr and Month Column.
The opposite operation to the Fill Down approach.

Workbook Link:
Solution:
Excel:
=HSTACK(MAP(B2:C14,LAMBDA(x,IF(COUNTIF(TAKE(B2:x,,-1),x)=1,x,""))),D2:D14)
Power Query:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Result = Table.FromColumns(List.Transform(Table.ToColumns(Source[[Qtr],[Month]]), (f) => List.Accumulate( List.Skip(f), {f{0}}, (s,c) => s & {if List.Contains(s,c) then null else c})) & {Source[Sales]}, Table.ColumnNames(Source))
in
Result
Python in Excel:
df = xl("B2:D14", headers=True)
df.mask(df.apply(lambda col: False if col.name == 'Sales' else col.duplicated()),'')





Comments