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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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.

 





Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.
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.

 





Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.
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)
 





Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

@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.

 





Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.