Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Was wondering how filter works in Power BI from evaluating a context's records.
If you have this:
Filter ( 'table'
, boolean 1
&& boolean 2
&& boolean 3
)
Will it by default work like this:
Or like this?
Solved! Go to Solution.
Hi @DouweMeer
The logical operator && follows the short-circuit evaluation rule. If multiple conditions are connected by && (e.g., A&&B&&C&&D), once any condition returns FALSE, the subsequent conditions will no longer be evaluated, and FALSE will be returned immediately.
You can verify the short-circuit property using the following formula:
Test =
IF (
TRUE() && FALSE() && DIVIDE(1, 0),
// Without short-circuiting, DIVIDE(1,0) would result in an error (division by zero error).
"True",
"False"
)
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @DouweMeer
The logical operator && follows the short-circuit evaluation rule. If multiple conditions are connected by && (e.g., A&&B&&C&&D), once any condition returns FALSE, the subsequent conditions will no longer be evaluated, and FALSE will be returned immediately.
You can verify the short-circuit property using the following formula:
Test =
IF (
TRUE() && FALSE() && DIVIDE(1, 0),
// Without short-circuiting, DIVIDE(1,0) would result in an error (division by zero error).
"True",
"False"
)
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I like your thought, but did you try to remove the false to test whether it returns in an error?
It doesn't :). Probably due to the divide expression on alternative result.
Which doesn't mean your assumption is false, just your argumentation is incorrect.
Versus
Thanks.
Hi @DouweMeer - In Power BI, you can apply the filters n daz as follows
FILTER ( 'table', 'table'[Boolean 1] && 'table'[Boolean 2] && 'table'[Boolean 3] )
This means that only rows where all three Boolean columns are TRUE will be returned.The correct filter result should only return Record 4, since it is the only row where all three Boolean values are TRUE.
So the filtering should work like neither image exactly but should result in a single-row table with only Record 4.
Hope this works.
Proud to be a Super User! | |
That was not the question. The question is not which record would return.
The question is how the boolean expressions are evaluated in the table. If boolean 1 would return false, would it even try to evaluate boolean 2 and boolean 3? Or would it go to the next record without verifying the second one?
User | Count |
---|---|
84 | |
76 | |
74 | |
49 | |
39 |
User | Count |
---|---|
114 | |
56 | |
51 | |
42 | |
42 |