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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
blep
Regular Visitor

Why does List.MatchesAll return true for an empty list?

The function documentation says that List.MatchesAll returns true if the condition function is satisfied by all values in the list, otherwise returns false.

 

Given a value x, I'd expect List.MatchesAll({}, each _ = x) to return false - how can the contents of the list all satisfy the condition of being equal to x if the list does not have any contents against which to test the condition?

 

For every value of x I've tried:

List.MatchesAll({}, each _ = x) returns true

List.MatchesAny({}, each _ = x) returns false

List.Contains({}, x) returns false

 

Can anyone explain this behaviour and why it is different for List.MatchesAll than it is for List.MatchesAny and List.Contains?

1 REPLY 1
mahoneypat
Microsoft Employee
Microsoft Employee

I wouldn't have guessed that behavior either, but I suspect it starts to iterate through the list with a TRUE condition, and since the list is empty there are no iterations/evaluations.  If you use {null} instead of {} it evaluates as FALSE, as it does do one iteration.

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.