10.3CALCULATETABLE

In Excel
ExcelFILTER
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.

CALCULATETABLE( <table>, [<filter> …] )

The syntax is the one of CALCULATE. Only the first argument changes. It is a table, and not an expression that returns a value.

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.

  1. 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
    BookingRoomNights
    R11012
    R22013
    R31021
    R42024

    Which formula should you write for “Suite Stays”?

  2. 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
    ZoneKilosPrice per Kilo
    North102
    South53
    North42.5
    East82

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.