Reverse of Fill Down in PQ

sadath

Active Member
Joined
Oct 10, 2004
Messages
262
Office Version
  1. 365
Platform
  1. Windows
Hi

How can i do the reverse of Fill Down in PQ.

ie remove the duplicate and keep only the first one in a column (Eg "Store" in the below code)


let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Store", type text}, {"Sales", Int64.Type}})
in
#"Changed Type"
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Using your posted example as the start of my Power Query code....
Here's what I did:
Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    SetDataTypes = Table.TransformColumnTypes(Source,{{"Store", type text}, {"Sales", Int64.Type}}),
    AddedIndex = Table.AddIndexColumn(SetDataTypes, "Index", 0, 1),
    GroupByName = Table.Group(AddedIndex, {"Store"}, {{"Group", each _, type table}}),
    AddGroupIndex = Table.TransformColumns(GroupByName, {{"Group", each Table.AddIndexColumn(Table.Sort(_,"Index"), "GroupIndex",1), type table}}),
    ExpandedGroup = Table.ExpandTableColumn(AddGroupIndex, "Group", {"Sales", "Index", "GroupIndex"}, {"Sales", "Index", "GroupIndex"}),
    SetNonFirstGroupRecordToNull = Table.FromRecords(Table.TransformRows(ExpandedGroup,(record) => Record.TransformFields(record,{"Store", 
        each if record[GroupIndex] =  1 then _ else null})))
in
    SetNonFirstGroupRecordToNull
Am I on the right track?
Is that something you can work with?
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,692
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top