Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi guys, I need help on the power query . My intention here is to remove the duplicate value for line and date . what i want is to make it so the query will only remove rows that has null value in [From] if any duplicate are found. Table below as an example:-
before
Date | Line | From |
1/1/2023 | 701 | 1 |
1/1/2023 | 701 | Null |
1/1/2023 | 701 | 1 |
1/2/2023 | 701 | 1 |
1/2/2023 | 702 | 1 |
1/2/2023 | 702 | Null |
1/3/2023 | 701 | Null |
what i expected the result to be
1) Row from 1/1/2023 [Line] 701 with null value on [From] is removed.
2) Row from 1/2/203 [Line] 702 with null value on [From] is removed.
3) Row from 1/3/2023 [Line]701 with null value on [From] is kept because no duplicate valuefor [Date] and [Line].
Date | Line | From |
1/1/2023 | 701 | 1 |
1/1/2023 | 701 | 1 |
1/2/2023 | 701 | 1 |
1/2/2023 | 702 | 1 |
1/3/2023 | 701 | Null |
Appreciate if anyone can help me on this. Thank you!
Solved! Go to Solution.
Hello, @screamout_93
let
Source = your_table,
#"Grouped Rows" = Table.Group(Source, {"Date", "Line"}, {{"Count", each Table.RowCount(_), Int64.Type}, {"rows", each _, type table [Date=datetime, Line=number, From=any]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "new_rows", each if [Count] > 1 then Table.SelectRows([rows], (x) => x[From] <> "Null") else [rows]),
result = Table.Combine(#"Added Custom"[new_rows])
in
result
Hello, @screamout_93
let
Source = your_table,
#"Grouped Rows" = Table.Group(Source, {"Date", "Line"}, {{"Count", each Table.RowCount(_), Int64.Type}, {"rows", each _, type table [Date=datetime, Line=number, From=any]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "new_rows", each if [Count] > 1 then Table.SelectRows([rows], (x) => x[From] <> "Null") else [rows]),
result = Table.Combine(#"Added Custom"[new_rows])
in
result
Thank you! your a lifesaver.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
29 | |
26 | |
23 | |
13 | |
10 |
User | Count |
---|---|
24 | |
21 | |
17 | |
11 | |
9 |