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! Learn more

Reply
jonbox
Helper II
Helper II

Compare rows and delete based on condition

Hi All, hopefully a simple request;

 

I have data similar to Table1 where the people in the "Name" column are in different "rooms". What i want is to get to the Table2 where if they're in room 5 specifically, remove all other rooms associated to their name e.g. for Jon, he's in room 5 so remove room 8, same for Ben where because he's in Room 5, remove room 6 and 3, whereas for Dan because he's not in room 5, keep Room 2 and Room 9.

 

Can anyone help on a formula where you look at all the rows per person, check if room 5 is there, if so delete every row except the one with room 5. If a person doesn't have a row with room 5, keep all the rows.

 

Hopefully that's clear! Thanks!

 

Table1:

NameRoom
JonRoom 5
JonRoom 8
BenRoom 6
BenRoom 3
BenRoom 5
AlexRoom 8
AlexRoom 5
AlexRoom 2
DanRoom 2
DanRoom 9

 

Table2:

NameRoom
JonRoom 5
DanRoom 5
AlexRoom 5
BenRoom 2
BenRoom 9
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @jonbox 

 

You can try the following methods.

Column:

Check Room 5 = 
Var _table=CALCULATETABLE(VALUES(Table1[Room]),FILTER(ALL(Table1),[Name]=EARLIER(Table1[Name])))
Var _N1=IF("Room 5" in _table,"Room 5",[Room])
Return
IF([Room]=_N1,[Room],BLANK())

vzhangti_0-1682474498002.png

New Table:

Table2 = FILTER(Table1,[Check Room 5]<>BLANK())

vzhangti_1-1682474573935.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @jonbox 

 

You can try the following methods.

Column:

Check Room 5 = 
Var _table=CALCULATETABLE(VALUES(Table1[Room]),FILTER(ALL(Table1),[Name]=EARLIER(Table1[Name])))
Var _N1=IF("Room 5" in _table,"Room 5",[Room])
Return
IF([Room]=_N1,[Room],BLANK())

vzhangti_0-1682474498002.png

New Table:

Table2 = FILTER(Table1,[Check Room 5]<>BLANK())

vzhangti_1-1682474573935.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.