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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
vojtechsima
Super User
Super User

IF Multiple Columns equal to Value (Power Query M)

Hello, guys,
I need to know if there's a formula or function that lets me list columns and if those columns equal to a certain value on each row I want to return some value.

 

For example:


A B C D E RESULT
TRUE TRUE TRUE TRUE TRUE TRUE
TRUE FALSE TRUE FALSE FALSE FALSE

 

Normally, I would write:

if
[A] = true or
[B] = true or
[C] = true or
[D] = true
then true else false


But I have lot of columns and this is getting really messy, I'd like to see if there's a function for it, similar to List.Contains.

So ideally something like this:

if ColumnContains({"A","B","C","D"}, true) = true then true else false


And I want to do in Power Query M for each row.

Sorry for the formatting but it didn't allow me to use the table somehow.

 
1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

You can use List.MatchesAny  but what's the logic of the second line being equal to FALSE?  If it follows the logic of the code you provided (each condition with an 'or'), it's TRUE

View solution in original post

5 REPLIES 5
CNENFRNL
Community Champion
Community Champion

 

= Table.AddColumn(#"Changed Type", "Result", each not List.Contains(Record.ToList(_),false))

 

CNENFRNL_1-1667284876271.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

@CNENFRNL 
Thank you for the effort, this checks if every column is the TRUE, right?
This doesn'T suit me, very well, in my real scenario but I agree, my example wasn't the best.

So thank you  for the effort.

 
HotChilli
Super User
Super User

You can use List.MatchesAny  but what's the logic of the second line being equal to FALSE?  If it follows the logic of the code you provided (each condition with an 'or'), it's TRUE

@HotChilli 
So I used your logic and it's correct, thank you, HotChilli.

vojtechsima_0-1667293159444.png

 

List.MatchesAny({[A], [B], [C], [D]}, each _ = true)
 

@HotChilli ,
Yeah my bad, I didn'T really check the logic, it was just to give an example, that I need to check multiple columns.

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.