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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Money
Helper I
Helper I

Remove duplicates of number

Hi all

I'm tring to remove duplicates from the column.

column presents numbers, - , and Taken. 

 

I need to remove only number duplicates and needs to keep "-" and "Taken" as it is. 

Sharing below the current data and expected data.

 

current dataexpected data

1

1
12
23
34
--
4taken
takentaken
taken5
56
3-
67
- 
7 

 

Please suggest me how to approach. 

Thanks in advance 🙂 

@tamerj1  @amitchandak @Greg_Deckler @Arul @v-zhangti @PowerQuerryGuru @Ashish_Mathur @FreemanZ

1 REPLY 1
AlexisOlson
Super User
Super User

You can do a Group By where you make sure "taken" and "-" are treated uniquely.

 

Here's a sample query you can paste into the Advanced Editor in a new blank query:

let
    Source = Table.FromColumns({{"1", "1", "2", "3", "-", "4", "taken", "taken", "5", "3", "6", "-", "7"}}, {"current data"}),
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each if [current data] = "taken" or [current data] = "-" then [Index] else 0, Int64.Type),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"current data", "Custom"}, {}),
    #"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"current data"})
in
    #"Removed Other Columns"

 This creates a unique index but then zeros it out for the numbers so that they aren't treated uniquely.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.