The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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.