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
kb177
Helper II
Helper II

remove all rows with same id and one specific value

Hi, I'm having multiple line with one order id and i want to remove all line for that order id if any one line contains word cancel 

as shown below order id 1 and all related lines should be removed. can there be any measure to filter such data or dax

order id  type

1            sell booked

1            payment received 

1            delivered

1            order cancel

2            sell booked

2            payment received

2            delivered

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Added Custom" = Table.AddColumn(Source, "Custom", each if Text.Contains([type],"cancel",Comparer.OrdinalIgnoreCase) then 1 else 0),
    #"Grouped Rows" = Table.SelectRows(Table.ExpandTableColumn(Table.Group(#"Added Custom", {"order id"}, {{"Count", each List.Sum([Custom]), type number}, {"All", each _, type table}}), "All", {"type"}, {"type"}), each [Count] = 0)[[order id],[type]]
in
    #"Grouped Rows"

 Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Added Custom" = Table.AddColumn(Source, "Custom", each if Text.Contains([type],"cancel",Comparer.OrdinalIgnoreCase) then 1 else 0),
    #"Grouped Rows" = Table.SelectRows(Table.ExpandTableColumn(Table.Group(#"Added Custom", {"order id"}, {{"Count", each List.Sum([Custom]), type number}, {"All", each _, type table}}), "All", {"type"}, {"type"}), each [Count] = 0)[[order id],[type]]
in
    #"Grouped Rows"

 Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ahmedx
Super User
Super User

pls see my video

https://1drv.ms/v/s!AiUZ0Ws7G26RiRJExYscE_ld_8CS?e=ffGJHq

(x)=> Table.SelectRows(x, (y)=> not  Text.Contains( y[type], "cancel",Comparer.OrdinalIgnoreCase))

Helpful resources

Announcements
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!

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