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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Removing duplicates by comparing multiple columns with condition

Hi there, 

 

I have this data where I want to remove duplicates. Essentially there are 3 service categories, GO, SVOD and SOTT. 

I would like to check for duplicates by comparing all the headers in the table. However here comes the complicated part. 
When one title have all three services, GO, SVOD and SOTT, I would like to remove the SOTT row. As it is a double count/entry for my data. Can this be done in query? Appreciate any help. Thanks.

 

Display CategoryTitleEpisodeTitleEpisode No.License Period Start DateLicense Period End DateService
ChooseDetectiveIs There A Detective on Board?113-Oct-219-Nov-21SVOD
ChooseDetectiveIs There A Detective on Board?113-Oct-219-Nov-21SOTT
ChooseDetectiveI Still Remember219-Oct-2115-Nov-21SVOD
ChooseDetectiveI Still Remember219-Oct-2115-Nov-21SOTT
ChooseDetectiveThat's Yui-nya319-Oct-2115-Nov-21SVOD
ChooseDetectiveThat's Yui-nya 319-Oct-2115-Nov-21SOTT
Outdoor Mission SurviveHighlights 661-Oct-2129-Dec-21SVOD
Outdoor Mission SurviveHighlights 661-Oct-2129-Dec-21SOTT
Outdoor Mission SurviveHighlights 661-Oct-2129-Dec-21GO
Outdoor Big AdventuresParty in Pensacola121-Oct-2130-Nov-21SVOD
Outdoor Big AdventuresParty in Pensacola121-Oct-2130-Nov-21SOTT
Outdoor Big AdventuresParty in Pensacola121-Oct-2130-Nov-21GO
Outdoor Big AdventuresThe Redfish 131-Oct-2130-Nov-21SVOD
Outdoor Big AdventuresThe Redfish 131-Oct-2130-Nov-21SOTT
Outdoor Big AdventuresThe Redfish 131-Oct-2130-Nov-21GO
PlanetWildlife2405-Oct-213-Nov-21SVOD
PlanetWildlife2405-Oct-213-Nov-21SOTT
PlanetWildlife2405-Oct-213-Nov-21GO
PlanetCrikey!Komodo95-Oct-213-Nov-21SVOD
PlanetCrikey!Komodo95-Oct-213-Nov-21SOTT
PlanetCrikey!Komodo95-Oct-213-Nov-21GO
PlanetLone StarMassacre115-Oct-213-Nov-21SVOD
PlanetLone StarMassacre115-Oct-213-Nov-21SOTT
PlanetLone StarMassacre115-Oct-213-Nov-21GO


Cheers
Darren

1 ACCEPTED SOLUTION
mussaenda
Super User
Super User

Hi @Anonymous 

 

I attached the pbix file for your reference.

It is not the finest query but you can get idea from it.

mussaenda_0-1666845639000.png

 

Thank you.

Regards,

Mia

View solution in original post

7 REPLIES 7
mussaenda
Super User
Super User

Hi @Anonymous 

 

I attached the pbix file for your reference.

It is not the finest query but you can get idea from it.

mussaenda_0-1666845639000.png

 

Thank you.

Regards,

Mia

Anonymous
Not applicable

just to clarify, everything is done in the advance editor? sorry, quite a newbie here. thanks.

So it groups all the columns and createa list and remove the duplicates there if it detects all 3 services? 

Hi @Anonymous ,

 

For clarification, it is done in Power Query.

Advanced editor is where you can see all the steps you do in Power Query.

 

Have you tested the file?

I suggest that you go though each applied step so you'll have the idea of each trasnformation.

 

Basically, I group by title, listed all the services, then created a filter that if there are all the services and the row is SOTT then I will hide it.

 

Hope this helps

Anonymous
Not applicable

Hi Mia, 

Thank you for your help. It worked now. I swapped the order of SOTT, Go, SVOD and it worked.

#"Added Custom1" = Table.AddColumn(#"Expanded Count", "Filter", each if Text.Contains([Service GRP], "GO")
and Text.Contains([Service GRP], "SVOD")
and Text.Contains([Service GRP], "SOTT")
and [Service] = "SOTT"

then null
else "Show"),
Anonymous
Not applicable

Hi there, 

 

I have tried step by step but in the end all my results are showing "Show", there is nothing in "null". I screwed up somewhere I think.  Here is the what from the advanced editor: 

 

let
    Source = Sql.Databases(""),
    CMS_DataWarehouse = Source{[Name="CMS_DataWarehouse"]}[Data],
    dbo_cms_ondemandtitles = CMS_DataWarehouse{[Schema="dbo",Item="cms_ondemandtitles"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(dbo_cms_ondemandtitles,{{"LicensePeriodStartDate", type date}, {"LicensePeriodEndDate", type date}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"DisplayCategory", "Channels"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Duration", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type1", each ([Service] <> "Linear")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Channels", "Title", "AltTitle", "EpisodeTitle", "EpisodeNumber", "SeasonNo", "Duration", "LicensePeriodStartDate", "LicensePeriodEndDate", "YearMonth"}, {{"Count", each _, type table [Channels=nullable text, Title=nullable text, AltTitle=nullable text,EpisodeTitle=nullable text,  EpisodeNumber=nullable text, SeasonNo=nullable text, #"Duration"=nullable number, LicensePeriodStartDate=nullable date, LicensePeriodEndDate=nullable date, YearMonth=nullable text, Service=nullable text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Service GRP", each let GetList =
Table.Column([Count], "Service"),

ExtractList = 
Text.Combine(List.Transform(GetList, Text.From), "#(lf)")

in 
ExtractList),
    #"Expanded Count" = Table.ExpandTableColumn(#"Added Custom", "Count", {"Service"}, {"Service"}),
    #"Added Custom1" = Table.AddColumn(#"Expanded Count", "Filter", each if Text.Contains([Service GRP], "GO")
and Text.Contains([Service GRP], "SVOD")
and Text.Contains([Service GRP], "SOTT")
and [Service] = "SOTT"

then null
else "Show"),
    #"Filtered Rows1" = Table.SelectRows(#"Added Custom1", each ([Filter] <> ""))
in
    #"Filtered Rows1"

hi @Anonymous,

 

before your last applied step,

dropdown the filter column, what are the values showing?

 

Anonymous
Not applicable

hi @mussaenda, it was only showing Show. There was nothing else. So I had to change to this and i can see show and null entries. 

#"Added Custom1" = Table.AddColumn(#"Expanded Count", "Filter", each if Text.Contains([Service GRP], "GO")
and Text.Contains([Service GRP], "SVOD")
and Text.Contains([Service GRP], "SOTT")
and [Service] = "SOTT"

then null
else "Show"),

thanks. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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 Kudoed Authors