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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Aggro
Frequent Visitor

Power Query Filter Data (List.Contains)

I'm using List Contains function from power query to filter the data that I need. 

I have a transaction list, transaction_list (in all text format), and a data table called data_table. 

When I use list contains to add a condition to the filtering process, it just doesn't work right. Keep giving me an error saying:Expression.Error: We cannot convert a value of type List to type Text.

 

FilteredTable = Table.SelectRows(Source, each
if Text.Start([transaction_list], 3) = "22-" then
List.Contains(transaction_list, [buyer_transaction_id])
else if Text.Start([transaction_list], 3) = "55-" then
List.Contains(transaction_list, [sell_transaction_id])
else
List.Contains(transaction_list, [transaction_id])

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Aggro ,

 

You may consider using the List.AnyTrue() function to minimize the number of List.Contains calls.

each List.AnyTrue({
    List.Contains(transaction_list, [transaction_id]),
    List.Contains(transaction_list, [sell_transaction_id]),
    List.Contains(transaction_list, [buyer_transaction_id])
})

List.AnyTrue() will only check for the first condition that is met, and once a match is found, it will stop checking the remaining ones, which can speed up the execution.

 

Best Regards,

Bof

View solution in original post

3 REPLIES 3
HotChilli
Super User
Super User

Text.Start needs a text parameter passed to it. It's getting the list passed to it.  What are you trying to do?

i'm searching for data from the transaction list.

Normally I would do:

 

each (List.Contains(transaction_list,[transaction_id])) or List.Contains(transaction_list,[sell_transaction_id])) or  List.Contains(transaction_list,[buyer_transaction_id]))

 

but it would take super long to filter out data. 

 

Anonymous
Not applicable

Hi @Aggro ,

 

You may consider using the List.AnyTrue() function to minimize the number of List.Contains calls.

each List.AnyTrue({
    List.Contains(transaction_list, [transaction_id]),
    List.Contains(transaction_list, [sell_transaction_id]),
    List.Contains(transaction_list, [buyer_transaction_id])
})

List.AnyTrue() will only check for the first condition that is met, and once a match is found, it will stop checking the remaining ones, which can speed up the execution.

 

Best Regards,

Bof

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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 Solution Authors
Top Kudoed Authors