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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
db400
Frequent Visitor

How to check if duplicate value exists in column after filter of another column?

The intention is to create a new column (Desired_Column) indicating whether a patient (Patient_ID) that completed a New Consult continued onto a Procedure.

 

DatePatient_IDVisit_TypeDesired_Column
1/3/23187New ConsultYes
1/5/23039Procedure 
1/7/23188New ConsultYes
1/10/23187Procedure 
1/16/23098Procedure 
1/20/23189New ConsultNo
1/23/23188Procedure 
1/25/23102Procedure 
1/25/23190New ConsultNo

 

I am rather new to using Power BI and am struggling on formulating a way to indicate whether Patient_ID still exists after Visit_Type is filtered to show "Procedure".

 

Thanks in advance.

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@db400 here it is , small tweak, when I tested at my end the date data type was text and that was the issue:

 

 

Column = 
VAR __Patient = Patient[Patient_ID]
VAR __Date = Patient[Date]
VAR __Table =
FILTER ( ALLSELECTED ( Patient ), [Patient_ID] = __Patient && Patient[Date] >= __Date && Patient[Visit_Type] <>  "NPC"  )
RETURN
IF ( Patient[Visit_Type] =  "NPC" , IF ( NOT ISEMPTY ( __Table ), "Yes", "No" ) ) 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

10 REPLIES 10
parry2k
Super User
Super User

@db400 here it is , small tweak, when I tested at my end the date data type was text and that was the issue:

 

 

Column = 
VAR __Patient = Patient[Patient_ID]
VAR __Date = Patient[Date]
VAR __Table =
FILTER ( ALLSELECTED ( Patient ), [Patient_ID] = __Patient && Patient[Date] >= __Date && Patient[Visit_Type] <>  "NPC"  )
RETURN
IF ( Patient[Visit_Type] =  "NPC" , IF ( NOT ISEMPTY ( __Table ), "Yes", "No" ) ) 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

db400
Frequent Visitor

It works flawlessly. Thank you so much!!

parry2k
Super User
Super User

@db400 I have no clue, you need to share the pbix file



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

db400
Frequent Visitor

parry2k
Super User
Super User

@db400 not sure why, can you make sure there are invisible spaces with "New Consult" values?

 

parry2k_0-1694628012870.png

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

db400
Frequent Visitor

I adjusted the table and formula to show "NPC" instead of "New Consult" instead to avoid any issues with invisible spacing and it still doesn't fix the issue. 

 

db400_0-1694628937205.png

 

parry2k
Super User
Super User

@db400 try using this DAX to add a calculated column:

 

Column = 
VAR __Patient = Patient[Patient_ID]
VAR __Date = Patient[Date]
VAR __Table =
FILTER ( ALLSELECTED ( Patient ), [Patient_ID] = __Patient && Patient[Date] <= __Date && Patient[Visit_Type] <> "New Consult" )
RETURN
IF ( Patient[Visit_Type] = "New Consult", IF ( NOT ISEMPTY ( __Table ), "Yes", "No" ) ) 


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

db400
Frequent Visitor

Thank you, but that didn't seem to give the desired results. Please see highlighted below.

 

db400_0-1694627882126.png

 

db400
Frequent Visitor

189 and 190 are no because they do not show up again in the table with a "Procedure" Visit_Type like 187 and 188 do.

parry2k
Super User
Super User

@db400 why 189 and 190 are no? What's the logic?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
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