Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
13 | |
13 | |
11 | |
8 | |
8 |
User | Count |
---|---|
17 | |
10 | |
7 | |
7 | |
7 |