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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

remove duplicates based on latest version using multiple selected columns

Hi Team,

 

there are 4 columns username, inventorydevicename, applicationproduct,version

username, inventorydevicename, applicationproduct, 3 columns values has same values but VERSION is having different for each row.

 

While deleting the duplicate rows then I have to use 4 columns, delete olderversion and keep latest version

 

source table:

username, inventorydevicename, applicationproduct,version

Assigned user - User nameInventory device - Inventory device nameApplication - ProductInstallation - Version
Abbott, RohanAUADL1LT91112d Model10
Abbott, RohanAUADL1LT91112d Model12
Abbott, RohanAUADL1LT91112d Model14
Abbott, RohanAUADL1LT91112d Model11

 

Expected output:

Abbott, RohanAUADL1LT91112d Model14

RajuM_0-1657527562619.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I'm keeping other columns apart from "Assigned user - User name", "Inventory device - Inventory device name", "Application - Product". but its not removing the duplicates in this case. could you pls suggest me

 

#"Grouped Rows" = Table.Group( #"Changed Type", {"Assigned user - User name", "Inventory device - Inventory device name", "Application - Product", "Installation - Publisher", "Installation - Application name", "Assigned user - Business Line","Inventory device - Location - last level","Assigned user - Corporate structure - 1st level","Assigned user - Corporate structure - 2nd level","Assigned user - Corporate structure - 3rd level","Assigned user - Corporate structure - last level","Inventory device - Cost center - 3rd level","Installation - Last used date","Calculated user - Email","Inventory device - Inventory date"},{{"Installation - Version",

each List.Max([#"Installation - Version"]), type nullable number}})
in
#"Grouped Rows"

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

I'm keeping other columns apart from "Assigned user - User name", "Inventory device - Inventory device name", "Application - Product". but its not removing the duplicates in this case. could you pls suggest me

 

#"Grouped Rows" = Table.Group( #"Changed Type", {"Assigned user - User name", "Inventory device - Inventory device name", "Application - Product", "Installation - Publisher", "Installation - Application name", "Assigned user - Business Line","Inventory device - Location - last level","Assigned user - Corporate structure - 1st level","Assigned user - Corporate structure - 2nd level","Assigned user - Corporate structure - 3rd level","Assigned user - Corporate structure - last level","Inventory device - Cost center - 3rd level","Installation - Last used date","Calculated user - Email","Inventory device - Inventory date"},{{"Installation - Version",

each List.Max([#"Installation - Version"]), type nullable number}})
in
#"Grouped Rows"

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

I gave you a new query in previous response. Does that work? If not, I will need sample output from your side.

Anonymous
Not applicable

@Vijay_A_Verma 

 

#"Grouped Rows" = Table.Group(#"Changed Type", {"Assigned user - User name", "Inventory device - Inventory device name", "Application - Product"}, {{"Installation - Version", each List.Max([#"Installation - Version"]), type nullable number}})
in
#"Grouped Rows"

 

in this M query: how do i keep invendotrydevicename,applicationprudction for max

List.Max([#"Installation - Version"])

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckxKyi8p0VEIys9IzFPSUXIMdXTxMfQJsTQ0BPIMjVIUfPNTUnNAbAOlWB2SNBiRqsGEVA2GSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Assigned user - User name" = _t, #"Inventory device - Inventory device name" = _t, #"Application - Product" = _t, #"Installation - Version" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Assigned user - User name", type text}, {"Inventory device - Inventory device name", type text}, {"Application - Product", type text}, {"Installation - Version", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Assigned user - User name"}, {{"Inventory device - Inventory device name", each List.Max([#"Inventory device - Inventory device name"]), type nullable text}, {"Application - Product", each List.Max([#"Application - Product"]), type nullable text}, {"Installation - Version", each List.Max([#"Installation - Version"]), type nullable number}})
in
    #"Grouped Rows"
Anonymous
Not applicable

hi @Vijay_A_Verma ,

 

when i use above code for groupby its working as expected...but its extracting 4 columns based on composite PK columns.... 

 

but sometimes inventorydevicename,application will have different product then we have to pick those column values.... 

 

I'm unable to attache the pbix file here..could u pls guide me on thisso that i would attach pbix file

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Easiest way is to group on first 3 columns and choose the max for 4th column

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckxKyi8p0VEIys9IzFPSUXIMdXTxMfQJsTQ0BPIMjVIUfPNTUnNAbAOlWB2SNBiRqsGEVA2GSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Assigned user - User name" = _t, #"Inventory device - Inventory device name" = _t, #"Application - Product" = _t, #"Installation - Version" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Assigned user - User name", type text}, {"Inventory device - Inventory device name", type text}, {"Application - Product", type text}, {"Installation - Version", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Assigned user - User name", "Inventory device - Inventory device name", "Application - Product"}, {{"Installation - Version", each List.Max([#"Installation - Version"]), type nullable number}})
in
    #"Grouped Rows"

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.