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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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