02.3The main operators
In Excel, you already use signs like +, > or &. In DAX, they work almost the same way. An is a sign placed between two values to carry out an operation. There are four families of them:
| Family | Signs |
|---|---|
| Calculation | +-*/ |
| Comparison | =<>><>=<= |
| Joining text | & |
| Combining conditions | &&|| |
02.3.1Calculating
The signs that calculate are the same as in Excel:
They add, subtract, multiply and divide. As in Excel, multiplication and division come before addition and subtraction. So 2 + 3 * 10 gives 32, not 50. To do the addition first, add parentheses, and ( 2 + 3 ) * 10 gives 50.
02.3.2Comparing
The signs that compare do not give a number, but an answer, TRUE or FALSE.
There are six of them. Each example compares a column, from Customers or Sales, to a value:
| Equal to | Customers[City] | = | "New York" | Equal to New York |
|---|---|---|---|---|
| Not equal to | Customers[City] | <> | "New York" | Not equal to New York |
| Greater than | Sales[Amount] | > | 100000 | Greater than 100,000 |
| Less than | Sales[Amount] | < | 100000 | Less than 100,000 |
| Greater than or equal to | Sales[Amount] | >= | 100000 | Greater than or equal to 100,000 |
| Less than or equal to | Sales[Amount] | <= | 100000 | Less than or equal to 100,000 |
This is what you write in a condition. An earlier lesson showed one:
For each sale, DAX answers TRUE or FALSE. FILTER keeps the sales where the answer is TRUE.
Watch out for the boundary value. Sale V004 has an amount of exactly 100,000. The condition Sales[Amount] > 100000 answers FALSE for it, because 100,000 is not greater than 100,000. The condition Sales[Amount] >= 100000 answers TRUE. Only >= keeps the boundary value.
Write >=, never =>. DAX does not recognize =>, and the formula returns an error. In the same way, write <=, never =<. So the equal sign always comes last.
Watch out also for the equal sign placed right after the name of a measure, in Revenue = SUM( Sales[Amount] ). That one compares nothing. It separates the name from the formula.
02.3.3Joining text
In a formula, a text is always written between double quotes, like "New York". Without quotes, DAX does not recognize the word, and the formula returns an error.
The & sign joins two texts, one after the other:
This expression gives “Sales in New York.” Notice the space at the end of "Sales in ". Without it, you would get “Sales inNew York.” This is how you build the title of a chart, like “Sales in New York in 2025.”
The & sign also joins a text and a . Let’s go back to the “Revenue” measure:
This expression gives “Total sales: 1700000.” The result of a measure comes with no space around it. So it is up to the text to provide one. Here, the space is at the end of "Total sales: ". Without it, you would get “Total sales:1700000.”
02.3.4Combining conditions
To require two conditions at once, join them with &&, which means “and”:
This condition is TRUE only for sales at a price of 25,000, of more than 5 cars.
For just one of the two to be enough, join them with ||, which means “or”:
This condition is TRUE for the customers from New York and for those from Chicago.
DAX also has the AND and OR functions, which do the same thing:
But AND and OR only accept two arguments. With three conditions, you have to slip one AND inside another. With && and ||, you simply chain them:
It is for this flexibility that && and || are usually preferred.
Quiz
The questions often rely on the course tables. Keep them in view in their floating window, which you can move and enlarge.
Question 1
The amounts of the sales are in the Sales table. Here is a condition:
Before you look, for how many sales does it answer TRUE?
Question 2
Sale V003 has a price of 25,000, for an amount of 100,000. Which condition keeps it?
Question 3
In the Products table, the Rano model is from the Velmo brand. Which formulas give the text “Velmo Rano,” with a space between the brand and the model? There are two, find them.
- An operator is a sign placed between two values. Depending on its family, it calculates, compares, joins text or combines conditions.
- A comparison gives TRUE or FALSE. The “>” sign leaves out the boundary value, the “>=” sign keeps it.
- AND and OR only accept two arguments. Prefer && and ||, which you can chain.