Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
Solved! Go to Solution.
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
= Table.AddColumn(#"Changed Type", "Result", each not List.Contains(Record.ToList(_),false))
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.
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.
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.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
71 | |
70 | |
38 | |
28 | |
26 |
User | Count |
---|---|
98 | |
96 | |
59 | |
44 | |
40 |