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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
db400
Frequent Visitor

How to check if ID value exists in another Type value column when filtered? (pbix file provided)

Having trouble creating formula for the Desired_Column. Logic is that "Yes" will show for a Patient_ID with Visit_Type that is not "New Consult" if there is another identical Patient_ID with Visit_Type of "New Consult".

 

DatePatient_IDVisit_TypeDesired_Column
1/3/23187New Consult 
1/5/23039ScanNo
1/7/23188New Consult 
1/10/23187LabYes
1/16/23039SurgeryNo
1/20/23189New Consult 
1/23/23188ScanYes
1/25/23102VisitNo
1/25/23190New Consult 
1/28/23190LabYes
1/29/23056ScanNo
1/30/23187SurgeryYes

 

 

Logic examples:

 

187's Lab visit on 1/10/23 and Surgery visit on 1/30/23 shows "Yes" because they had a "New Consult" visit on 1/3/23.

 

039's Scan visit on 1/5/23 shows "No" because they have no "New Consult" visit, only a Surgery visit on 1/16/23.

 

188's Scan visit on 1/23/23 shows "Yes" because they had a "New Consult" visit on 1/7/23.

 

 

Link to .pbix file: 

https://drive.google.com/file/d/1BvQ8OwRuMjXKTMLHHuTCX7aVcGaxq7J6/view?usp=sharing

 

 

Thank you in advance!

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@db400 thanks for making this a seperate post, otherwise a lot of people keep on asking the question on the existing post even though it is a new requirement. Kudos to you for following the etiquette to post a question. Thank you!

 

Well, this is what I think you are looking for:

 

Column 2 = 
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.

View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

@db400 one more request, when you reply to the post, make sure to tag the person you are working with. 

 

BTW, you ran into the same issue, the data type of the date column in your file is text, change it to date and it will work.



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 

Works beautifully. Thanks again for your help and also for the post feedback!

parry2k
Super User
Super User

@db400 and the link you shared to download the file is not working.

 

I think if you share sample data and clearly outline the logic, that is sufficient, sharing pbix file surely helps.



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.

parry2k
Super User
Super User

@db400 working at my end, I just pasted the data from your post and worked on it, not downloading the pbix file, Maybe there is something different in the file like the previous one:

 

parry2k_0-1694637778239.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

That's strange.. I have tried re-doing the column adding but I am still getting the same problem.

 

The correct .pbix file link: 

https://drive.google.com/file/d/1BvQ8OwRuMjXKTMLHHuTCX7aVcGaxq7J6/view?usp=drive_link

parry2k
Super User
Super User

@db400 thanks for making this a seperate post, otherwise a lot of people keep on asking the question on the existing post even though it is a new requirement. Kudos to you for following the etiquette to post a question. Thank you!

 

Well, this is what I think you are looking for:

 

Column 2 = 
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

Thanks again for your help! I'll be posting quite a few help requests in the future so please let me know if there's anything else I should include in posts to make it easier for those helping.

 

It seems like the provided formula is not returning the desired result, please see highlighted below.

 

db400_0-1694637644399.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.