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
jimmyhua
Helper I
Helper I

Compares a list of single values (list1) against a list of 2 values

compare_lists(list1, list2):

Compares a list of single values (list1) against a list of pairs (list2),
returning a list of indices where a match is found in the second list.

list1: List of single values.
list2: List of pairs (tuples or lists with 2 elements).

how to write using Power Query

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi @jimmyhua 

 

= List.Transform(List1, (x) => List.PositionOf(List.Transform(List2, each List.Contains(_, x)), true) +1)

Stéphane 

View solution in original post

4 REPLIES 4
slorin
Super User
Super User

Hi @jimmyhua 

 

= List.Transform(List1, (x) => List.PositionOf(List.Transform(List2, each List.Contains(_, x)), true) +1)

Stéphane 

Omid_Motamedise
Super User
Super User

You can use List.Transform. Imagine List2 is {{1,2},{2,3},{2,4},{4,5}} and you are searching for 2 (it is better to be a value not list but if it was a single item list, use List1{0} to convert it to number), use the next formula to check which lists inside the second list include 2


List.Transform({{1,2},{2,3},{2,4},{4,5}}, each List.Contains(_,2))


If my answer helped solve your issue, please consider marking it as the accepted solution.

here is two sample lists.  

list 1: = {"C",1,"D",4}
list 2: = {{1,"A"},{2,"B"},{3,"C"},{4,"D"}}

 

how to find each list 1 item in list 2 and provide a position number.  don't care whether it is the first item or the second item, just within which list2 pairs.

sanalytics
Super User
Super User

@jimmyhua 
Please go through the below link before posting any question here.
https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/td-p/144...
going forward please provide some dummy data along with your output screenshot. it will help us to provide the solution.

 

Regards,

sanalytics

 

 

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