Power query IF AND OR

Hi @pedroccamara

If I correctly understand your query then you want to understand how the logical operator works. As these are logical operator so as per my understanding it will evaluate from left to right.

To simplify lets just do all the comparison first and get true or false and then apply logical operation.

  1. It will check [Debit] > 0 — and the result will be true1 or false1
  2. Text.StartsWith([AccountID], “2781”) — and the result will be true2 or false2
  3. Text.StartsWith([AccountID], “2782”) — and the result will be true3 or false3
  4. [Grp 03 Acc] = “232” — and the result will be true4 or false4

So now your expression will reduce to as below (assume all condition meets true)

if true1 and true2 or true3 and true4 then “i will have all the credits records for all those 3 accounts”

Now it will compare first and operator which is in between true1 and true2 it will result in true12. Now rewriting the expression

if true12 or true3 and true4 then “i will have all the credits records for all those 3 accounts”

Now it will compare or operator which is in between true12 and true3 it will result in true123. Now rewriting the expression

if true123 and true4 then “i will have all the credits records for all those 3 accounts”

Now it will compare and operator which is in between true123 and true4 it will result in true1234. Now rewriting the expression

if true1234 then “i will have all the credits records for all those 3 accounts”

And finally the output will be — “i will have all the credits records for all those 3 accounts”

Hope this explanation is ok …

Thanks
Mukesh