Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
Solved! Go to Solution.
Hi @jimmyhua
= List.Transform(List1, (x) => List.PositionOf(List.Transform(List2, each List.Contains(_, x)), true) +1)
Stéphane
Hi @jimmyhua
= List.Transform(List1, (x) => List.PositionOf(List.Transform(List2, each List.Contains(_, x)), true) +1)
Stéphane
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))
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.
@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
Check out the July 2025 Power BI update to learn about new features.