Power Query next repeat cell value replace with null

srehman

Board Regular
Joined
Jan 4, 2020
Messages
210
Office Version
  1. 2016
Platform
  1. Windows
Column A. Result Column PQ

3. 3
3. Null
1. 1
4. 4
7. 7
9. 9
9. Null
9. Null
9. Null
20. 20
20. Null
11. 11
8. 8
There is no dot sorry typing in mobile. Looking for simple solution in power query b.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Add a faux rankif column using ideas here. Add a conditional column where rank 1 keeps its value and higher is null.
 
Upvote 0
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table8"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Sorted Rows" = Table.Sort(#"Added Index",{{"Column1", Order.Ascending},"Index"}),
    #"Added Index1" = Table.AddIndexColumn(#"Sorted Rows", "Index.1", 0, 1, Int64.Type),
    #"Added Conditional Column" = Table.AddColumn(#"Added Index1", "Custom", each if [Column1] = #"Added Index1"[Column1]{[Index.1]-1} then null else [Column1]),
    #"Replaced Errors" = Table.ReplaceErrorValues(#"Added Conditional Column", {{"Custom", #"Added Index1"[Column1]{0}}}),
    #"Sorted Rows1" = Table.Sort(#"Replaced Errors",{{"Index", Order.Ascending}}),
    #"Removed Columns" = Table.RemoveColumns(#"Sorted Rows1",{"Column1", "Index", "Index.1"})
in
    #"Removed Columns"
 
Upvote 0
Power Query:
= List.Accumulate(Source[Title],{},(x,y)=>x&(if List.Contains(x,y) then {null} else {y}))
1626925285659.png


Source table:
1626925340066.png
 
Upvote 0
if there is duplicate value like below:
1626925857729.png

changed the code to :
Power Query:
= List.Accumulate(Source[Title],{},(x,y)=>x&(if y=List.Last(x) then {null} else {y}))
1626925904276.png
 
Upvote 0
If the list contains lots of data, my solution in post #4 and #5 may show stack overflow error.
 
Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,977
Members
452,540
Latest member
haasro02

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