Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
gpl
Frequent Visitor

Remove Duplicates Except 0

Thanks in advance to anyone who helps!

 

I am trying to remove duplicates except 0's and cant seem to figure it out.. help please!

 

6/2/201920870
6/2/201920870
6/2/20190
6/2/20190
6/2/20190
6/2/201920947
6/2/20190
6/2/20190
6/2/201920947
6/2/201920949
6/2/201920949
6/2/20190
6/2/20190
6/2/201920955
6/2/201920955
6/2/201920956
6/2/201920956
6/2/201920958
6/2/201920958
2 ACCEPTED SOLUTIONS
TomMartens
Super User
Super User

Hey,

i did not test this but maybe this would work, the idea create two tables, filter for all rows that are zero and the 2nd table <> 0, make the 2nd table distinct like so (DAX pseudocode 🙂 😞

NEWTABLE =
UNION(
CALCULATETABLE(<tablename>, value = 0)
,DISTINCT(CALCULATETABLE(<tablename>, value <> 0))
)

Hopefully this provides some ideas.

Regards,
Tom


Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

Anonymous
Not applicable

In Power Query:

  • Groupby Date and Value. Aggregating for all Rows and Count

1. Groupby.png

 

Then add an index column to each sub-table. 

Table.AddIndexColumn([AllData],"Index",1,1)

Remove the other columns, only need the subtable with the index column and the count

Expand the table out

Add a new column with the folowing:

2. Custom Column.png

then filter out that column for "keep" and remove other columns and set data types

 

Final Table:

Final Table.png

 

File:

https://1drv.ms/u/s!Amqd8ArUSwDS3AtSNswgChcZdaUF?e=qWpb0l

View solution in original post

4 REPLIES 4
jdbuchanan71
Super User
Super User

Hello @gpl 

We can do what you are looking for like this:

Add an index column to the data
Modify the index so it wont match any values on accident
Add a column that checks if the value is 0, if so bring the index, if not, bring the date and value. (this assumes if you have the same value on different dates you want to see each date/value pair.
Remove duplicates on the last column we just added.
Remove all the columns we added.

 

Example excel file with the PowerQuery, will also work in PowerBI. 

https://www.dropbox.com/s/oqcdopy9sca5z0g/KeepZeroDupes.xlsx?dl=0

 

keepserodupes.jpg

 

Anonymous
Not applicable

In Power Query:

  • Groupby Date and Value. Aggregating for all Rows and Count

1. Groupby.png

 

Then add an index column to each sub-table. 

Table.AddIndexColumn([AllData],"Index",1,1)

Remove the other columns, only need the subtable with the index column and the count

Expand the table out

Add a new column with the folowing:

2. Custom Column.png

then filter out that column for "keep" and remove other columns and set data types

 

Final Table:

Final Table.png

 

File:

https://1drv.ms/u/s!Amqd8ArUSwDS3AtSNswgChcZdaUF?e=qWpb0l

TomMartens
Super User
Super User

Hey,

i did not test this but maybe this would work, the idea create two tables, filter for all rows that are zero and the 2nd table <> 0, make the 2nd table distinct like so (DAX pseudocode 🙂 😞

NEWTABLE =
UNION(
CALCULATETABLE(<tablename>, value = 0)
,DISTINCT(CALCULATETABLE(<tablename>, value <> 0))
)

Hopefully this provides some ideas.

Regards,
Tom


Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
DouweMeer
Impactful Individual
Impactful Individual

Hello @gpl 

 

Perhaps create an initial validation step before the distinct? I believe they recently introduced the operator == to filter out the blanks. 

 

You could also think of a union of the the filtered table with just but 0's and the distinct values. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors