Is there a way to remove the yellow records with Power Query, Python?
They are errors and I need to get rid of them:
The process could be something like:
- Filter the table to retrieve the rows containing only the current “CustomerID”
- Check the Sales. Is there any value with -Sales?
And then delete those rows.
Advertisement
Answer
You may use following technique:
JavaScript
x
10
10
1
let
2
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
3
add = Table.AddColumn(Source, "Abs", each Number.Abs([Sales])),
4
group = Table.Group(add, {"Customer ID", "Abs"}, {{"sum", each List.Sum([Sales])},
5
{"all", each Table.RemoveColumns(_, "Abs")}}),
6
filter = Table.SelectRows(group, each ([sum] <> 0)),
7
final = Table.Combine(filter[all])
8
in
9
final
10