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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
pythongtdax
Frequent Visitor

How to check if two pipe delimited columns (Paths )have any common values using DAX?

Let's say I have two columns A = (1|2|3) and B = (2|3|4). 

 

How can I check if they contain any common values? In the above case, the result I want is True.

 

For A = (1|2|3) and B = (5|6|7), the result should be false as there are no common values. 

 

I need a DAX solution as I need to use this in Row Level Security.

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Here's a DAX solution.  

 

 

A common B = 
var ta = SELECTCOLUMNS(ADDCOLUMNS(GENERATESERIES(1,PATHLENGTH([A])),"Item",PATHITEM([A],[Value])),"Item",[Item])
var tb = SELECTCOLUMNS(ADDCOLUMNS(GENERATESERIES(1,PATHLENGTH([B])),"Item",PATHITEM([B],[Value])),"Item",[Item])
return COUNTROWS(INTERSECT(ta,tb))>0

 

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @pythongtdax ,

 

Table.

vcgaomsft_1-1649312280754.png

Please try this measure.

Result = IF(COUNTROWS(INTERSECT(VALUES('Table'[A]),VALUES('Table'[B])))>0,TRUE(),FALSE())

vcgaomsft_0-1649312246608.png

Table2.

vcgaomsft_2-1649312310125.png

Measure.

Result_2 = IF(COUNTROWS(INTERSECT(VALUES('Table2'[A]),VALUES('Table2'[B])))>0,TRUE(),FALSE())

vcgaomsft_3-1649312363496.png

 

Attach the PBIX file for reference. Hope it helps.

 

Best Regards,
Community Support Team_Gao

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

lbendlin
Super User
Super User

Here's a DAX solution.  

 

 

A common B = 
var ta = SELECTCOLUMNS(ADDCOLUMNS(GENERATESERIES(1,PATHLENGTH([A])),"Item",PATHITEM([A],[Value])),"Item",[Item])
var tb = SELECTCOLUMNS(ADDCOLUMNS(GENERATESERIES(1,PATHLENGTH([B])),"Item",PATHITEM([B],[Value])),"Item",[Item])
return COUNTROWS(INTERSECT(ta,tb))>0

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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