Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I have a problem with PowerQuery. So, I need to apply Distinct function in my table.
But with one condition: repeatable values should be deleted if their value is greater than 0.
Please help me to write a fuction on PowerQuery M. Maybe it's possible to use IF-expression?
Example, if 'ID'>0 then Table.Distinct(#"", {"ID"}) else 0.
Thanks!
Solved! Go to Solution.
this should work
Table.FromRows(List.Distinct(Table.ToRows(Source),each if _{0}=0 then Text.NewGuid() else _{0}))
Not quite. For example, here is a column:
0 |
0 |
20155 |
20156 |
20157 |
20157 |
20157 |
0 |
20158 |
20159 |
Needs to delete duplicated values 20157 (two times). Nulls should stay in a column as they are.
Here is a required result:
0 |
0 |
20155 |
20156 |
20157 |
0 |
20158 |
20159 |
this should work
Table.FromRows(List.Distinct(Table.ToRows(Source),each if _{0}=0 then Text.NewGuid() else _{0}))
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
14 | |
12 | |
11 | |
10 | |
9 |