03.5A value or a table: scalar and tabular
Some of your formulas return a number, others a list of rows. This difference decides what a measure can contain, and how to get its result.
03.5.1A value or a table
A DAX formula returns either a single value, or a table.
SUM returns a value, 1,700,000. In DAX, it is called a scalar:
FILTER returns a table, the customers in New York. Its result is called tabular:
03.5.2The result of a measure is a single value
A visual expects a single value where it shows a measure, in a card or on each row of a table. It cannot place a table there.
So FILTER alone cannot be a measure:
Power BI reports an error.
03.5.3Virtual tables (a quick look)
To get the result of a measure, you will sometimes need a table that serves as a step along the way. You then write in the measure a function that creates a table. FILTER is one of them, but many other DAX functions also return a table. The table created this way is called a virtual table. It exists only for the time of the calculation. It does not appear in the Data pane, and no visual shows it.
The Sales, Customers and Products tables, on the other hand, are physical tables. You see them in the Data pane.
To see a virtual table, open the DAX query view of Power BI. Write the formula of the table there, without a measure name, starting directly with EVALUATE.
Then click Run. Power BI shows the rows of the table, here the customers in New York.
| Customers[Name] | Customers[Type] | Customers[Customer ID] | Customers[City] | |
|---|---|---|---|---|
| 1 | Orvane | Company | C001 | New York |
| 2 | Kumora | Company | C002 | New York |
| 3 | Talvio | Company | C003 | New York |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
To see a value in the query view, place it between braces. EVALUATE expects a table, and the braces turn the value into a table of a single row:
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
You create the measure Sedans = FILTER( Products, Products[Category] = "Sedan" ). What happens?
Question 2
The measure COUNTROWS( FILTER( Sales, Sales[Qty] > 5 ) ) returns 6. Where can you then find the table of 6 sales that FILTER created?
Question 3
In the query view, you write EVALUATE SUM( Sales[Amount] ). Power BI reports an error. What do you need to change?
- A DAX formula returns either a single value, a scalar, or a table.
- The result of a measure is always a single value. A virtual table, like the one from FILTER, can serve as a step. It exists only for the time of the calculation.