10.3CALCULATETABLE
In Excel
| Excel | FILTER |
|---|---|
| Match |
CALCULATE returns a single value. Sometimes you will need a table filtered the same way. Its neighbor, CALCULATETABLE, changes the context the same way, but returns a table.
10.3.1A table, in a changed context
CALCULATETABLE returns a table, and not a single figure, after placing the filters you write. It works like CALCULATE, but it receives a table instead of a calculation. It is useful, for example, to get the rows that meet a filter.
In our data, these are for example the Toronto sales, row by row, in the query view.
CALCULATETABLE changes the filter context, then returns the table of its first argument in this context.
The syntax is the one of CALCULATE. Only the first argument changes. It is a table, and not an expression that returns a value.
| Sales[Sale ID] | Sales[Date] | Sales[Customer ID] | Sales[Product Code] | Sales[Qty] | Sales[Price] | Sales[Amount] | |
|---|---|---|---|---|---|---|---|
| 1 | V005 | 11/25/2024 | C006 | A201 | 6 | 25000 | 150000 |
| 2 | V011 | 9/30/2025 | C007 | A202 | 2 | 50000 | 100000 |
| 3 | V012 | 12/2/2025 | C006 | A102 | 5 | 10000 | 50000 |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
The filter is on Customers, and the table returned is Sales. The filter goes through the relationship, like the filter of a slicer, and Sales keeps only the 3 sales of the Toronto customers.
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 hotel stores its stays in the “Bookings” table. The “Rooms” table, linked to “Bookings” by the “Room” column, gives the type of each room in its “Type” column, and only rooms 201 and 202 are suites. Create the “Suite Stays” calculated table, which keeps the bookings of the rooms of type “Suite.”
Bookings Booking Room Nights R1 101 2 R2 201 3 R3 102 1 R4 202 4 Which formula should you write for “Suite Stays”?
Combined useMeasureDifficulty
A carrier records its deliveries in the “Deliveries” table, with the zone, the kilos and the price per kilo. Write the “North Billing” measure, shown in a card, the amount billed for the deliveries of the “North” zone only.
Deliveries Zone Kilos Price per Kilo North 10 2 South 5 3 North 4 2.5 East 8 2
The rest of this lesson is part of izyDAX Pro
You have just read the first section. The next 3, their animations, the exercises and the summary are waiting for you with izyDAX Pro, in a single payment.