13.1Knowing what the visual filters
In a visual, you will sometimes want a calculation that changes with the row it sits on, for example a title that names the selected city. These six functions query the filter context to find out what the visual filters.
13.1.1The table the visual builds
A table by city shows, on each row, the revenue of the city. Before drawing this table, Power BI builds a table.
Power BI first builds a table, then draws it. It has one row per value of the axis, here a city, and one column per measure. The table, the line chart or the matrix is only the way this table is drawn.
| City | Revenue |
|---|---|
| New York | 900,000 |
| Chicago | 500,000 |
| Toronto | 300,000 |
| Total | 1,700,000 |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
Each row of this table is a filter context. The revenue of the New York row is calculated with the filter “City = New York”, and that of the “Total” row with no city filter.
Power BI Desktop shows this table:
- Click the visual.
- Open the Data / Drill tab of the ribbon.
- Click Visual table. The table appears under the visual.
- Click Back to report to return.
The measures placed in the “Tooltips” field of the visual appear there too, as extra columns. The visual does not show them in the drawing, but Power BI calculates them with the others.
A measure can return a different result from one level of the hierarchy to the next. The revenue here comes from a measure “Revenue (0 if blank)”, which shows 0 when there is no sale, while the ordinary measure would stay blank. Let us also take a measure “Period”, placed in “Tooltips”, which shows the dates of a week, and only when the visual groups its rows by week. ISINSCOPE, seen later, runs this test. Here is this measure, as it is written in the Power BI file:
“I want to show the start and end dates of the week, but only when the visual groups its rows by week.”
The two variables keep the earliest and the latest date of the row. ISINSCOPE answers TRUE only when the visual groups its rows by week. Otherwise, IF returns nothing. At the “Month” level, the visual table therefore shows a blank “Period” column:
| Month | Revenue (0 if blank) | Period |
|---|---|---|
| Jan 2024 | 250,000 | |
| Feb 2024 | 0 | |
| Mar 2024 | 150,000 | |
| Total | 400,000 |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
At the “Week” level, the same measure returns the dates of each row:
| Week | Revenue (0 if blank) | Period |
|---|---|---|
| W1’24 | 0 | 01/01/24 - 01/07/24 |
| W2’24 | 0 | 01/08/24 - 01/14/24 |
| W3’24 | 250,000 | 01/15/24 - 01/21/24 |
| W4’24 | 0 | 01/22/24 - 01/28/24 |
| Total | 250,000 |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
The measure is the same in both tables. Only the level of the visual changes, and the visual table makes it visible. Without it, a blank tooltip at the “Month” level looks like a bug.
When a number surprises you, read the table before the drawing. A month at 0 or blank, an extra row, a total that does not match the rows all show there with their exact value, without formatting.
The rest of this lesson is part of izyDAX Pro
You have just read the first section. The next 6, their animations, the exercises and the summary are waiting for you with izyDAX Pro, in a single payment.