13.2Building a table
You will sometimes need a table that does not exist yet, with one more column, only a few columns, or grouped rows. These functions build it. Their tables serve as calculated tables, or as virtual tables inside a measure. The DAX query view shows their result.
13.2.1ADDCOLUMNS
In Excel
| Excel | HSTACK(table,calculation) |
|---|---|
| Match |
In a visual, Power BI adds the revenue next to each customer on its own. ADDCOLUMNS helps you when you write the table yourself, in the query view or in a formula, and it lacks a calculated column.
ADDCOLUMNS adds one or more columns to a table. Each column has a name in quotes and an expression.
| Customers[Customer ID] | Customers[Name] | Customers[Type] | Customers[City] | [Revenue] | |
|---|---|---|---|---|---|
| 1 | C001 | Orvane | Company | New York | 450000 |
| 2 | C002 | Kumora | Company | New York | 300000 |
| 3 | C003 | Talvio | Company | New York | 150000 |
| 4 | C004 | Ribelia | Company | Chicago | 250000 |
| 5 | C005 | Movara | Company | Chicago | 250000 |
| 6 | C006 | Northel | Company | Toronto | 200000 |
| 7 | C007 | Sam Lee | Individual | Toronto | 100000 |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
On each row, the measure is calculated for the customer of the row. Calling a measure turns the row into a filter, like CALCULATE in a calculated column.
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
This move from the row to a filter is called context transition. It was covered in detail earlier in the course.
Practice
Each exercise is solved with the function you just discovered. Two exercises per function, a direct use and a combined use, from easiest to hardest, on data other than the course data. Pick the right formula out of five.
Direct useCalculated tableDifficulty
A library has a “Books” table and a “Loans” measure, the number of loans. Create the calculated table “Books and Loans”, which takes “Books” and adds the “Loans” column to it, calculated with the measure.
Books Title Genre Dune Science fiction Emma Novel Ubik Science fiction Which formula should you write for “Books and Loans”?
Combined useCalculated tableDifficulty
A weather station records the lowest and highest temperature every day, in the “Readings” table. Create the calculated table “Detailed Readings”, which takes “Readings” and adds two columns to it, “Range”, max − min, then “Average”, (max + min) / 2.
Readings Day Min Max 7/1/2026 12 24 7/2/2026 15 27 7/3/2026 10 20
The rest of this lesson is part of izyDAX Pro
You have just read the first section. The next 4, their animations, the exercises and the summary are waiting for you with izyDAX Pro, in a single payment.