Našimi kurzy prošlo více než 10 000+ účastníků
2 392 ověřených referencí účastníků našich kurzů. Přesvědčte se sami
This is about the basic logic of conditions in Power Query M.
For conditions there is very useful button “Conditional column” – but it works only for one condition or for multiple conditions going one by one. If you need logical operators or nesting of conditions, you have to write them “manually”.
How to do it?
Let´s use this table, containing information about cars.
The first condition recognizes, whether the car is Porsche or not. In a custom column it looks like this:
and the whole step in M looks like this:
This condition recognizes Fords, Porsches, Fiats and another brands. If multiple conditions are true, then only the first one is accepted.
In a Custom column it looks like this.
You can use the AND operator. This condition recognizes, whether it is a silver Porsche or not.
The OR operator works analogically to AND. This condition recognizes cars, that are either silver, or Porsche, or silver Porsche.
How it works when you need blue Fords and silver Porsches?
But what if you need to find cars, that are Fords or Porsches, but silver only?
If you tried this, it wouldn’t work. It would find all Porsches, regardless of color, and silver Fords.
We need brackets to set the priorities. So first of all we´ll find, whether it is one of the brands we need, and then the color is checked.
Let´s come back to an example when we were looking for silver Porsches, but now we don´t want to use AND.
This example can be handled using nested conditions (brackets are not necessary here):
2 392 ověřených referencí účastníků našich kurzů. Přesvědčte se sami
Pište kdykoliv. Odpovíme do 24h
© exceltown.com / 2006 - 2023 Vyrobilo studio bARTvisions s.r.o.