FIRST
In a visual calculation, a column's value at the first row along an axis.
A visual calculation works on the table behind a visual: a row for each group on the visual's axes and one for each of their totals. To try one in the OAX view, give a table that shape with DEFINE TABLE ... WITH VISUAL SHAPE: its axes, their groups, the TRUE/FALSE column that marks each group's totals and the order, and with DENSIFY a name for the column that marks rows the shape fills in. Then write the calculation as a COLUMN of that table, as Power BI's own queries do. The examples below are queries of that kind, small enough to check by hand.
Group: Window and visual calculations. Compatible with DAX.
Syntax
FIRST ( <column> [, <axis>] [, <orderBy>] [, <blanks>] [, <reset>] )
| Parameter | Type | Description |
|---|---|---|
column | Column | A field of the visual, such as [Liters]. An expression is not allowed here: make it a visual calculation of its own and name that. |
axis | Axis optional | Which way to go: ROWS or COLUMNS, or both, as ROWS COLUMNS, which goes down the rows first and then across the columns; ROWPAGES for small multiples. Left out, the visual's first axis. |
orderBy | ORDERBY optional | ORDERBY ( ... ) to take the rows in another order than the axis has. |
blanks | Keyword optional | With an ORDERBY: where blank values go, DEFAULT, FIRST or LAST. |
reset | Reset optional | Where it starts again: NONE (when left out) never; HIGHESTPARENT (or 1, or the axis's top column) at each value of the top group; LOWESTPARENT (or -1) at each row's own parent; another whole number, or a column of the axis, at that level. |
Returns
Same type as the column. The column's value on the first row along the axis.
Remarks
[Liters] - FIRST ( [Liters] )shows how far each row has moved from the start.- Each level of the visual is walked on its own: the quarters' rows among the quarters, the years' subtotals among the years, the grand total by itself. With
HIGHESTPARENT, each year's quarters compare with that year's first quarter. - It is the visual calculation's counterpart of
INDEX ( 1 )along an axis. - It works only in a visual calculation; in a measure, a calculated column or a plain query it is an error.
Examples
Against the first month
Four months on the rows of a visual.
DEFINE
TABLE Visual =
DATATABLE (
"Month", INTEGER, "Liters", INTEGER,
{ { 1, 100 }, { 2, 150 }, { 3, 120 }, { 4, 90 } }
)
WITH VISUAL SHAPE
AXIS ROWS GROUP [Month] ORDER BY [Month]
DENSIFY "Added"
COLUMN Visual[First] = FIRST ( [Liters] )
COLUMN Visual[Since the first] = [Liters] - FIRST ( [Liters] )
EVALUATE
SELECTCOLUMNS (
Visual,
"Month", [Month], "Liters", [Liters],
"First", [First],
"Since the first", [Since the first]
)
ORDER BY [Month]
| Month | Liters | First | Since the first |
|---|---|---|---|
| 1 | 100 | 100 | 0 |
| 2 | 150 | 100 | 50 |
| 3 | 120 | 100 | 20 |
| 4 | 90 | 100 | -10 |
The first quarter of each year
DEFINE
TABLE Visual =
DATATABLE (
"Year", INTEGER, "Quarter", INTEGER, "Liters", INTEGER, "All years", BOOLEAN, "All quarters", BOOLEAN,
{
{ 2025, 1, 100, FALSE, FALSE }, { 2025, 2, 120, FALSE, FALSE }, { 2025, BLANK (), 220, FALSE, TRUE },
{ 2026, 1, 130, FALSE, FALSE }, { 2026, 2, 150, FALSE, FALSE }, { 2026, BLANK (), 280, FALSE, TRUE },
{ BLANK (), BLANK (), 500, TRUE, TRUE }
}
)
WITH VISUAL SHAPE
AXIS ROWS
GROUP [Year] TOTAL [All years]
GROUP [Quarter] TOTAL [All quarters]
ORDER BY [Year], [Quarter]
DENSIFY "Added"
COLUMN Visual[First overall] = FIRST ( [Liters] )
COLUMN Visual[First of the year] = FIRST ( [Liters], HIGHESTPARENT )
EVALUATE
SELECTCOLUMNS (
Visual,
"Year", [Year], "Quarter", [Quarter], "Liters", [Liters],
"First overall", [First overall],
"First of the year", [First of the year]
)
ORDER BY ISBLANK ( [Year] ), [Year], ISBLANK ( [Quarter] ), [Quarter]
| Year | Quarter | Liters | First overall | First of the year |
|---|---|---|---|---|
| 2025 | 1 | 100 | 100 | 100 |
| 2025 | 2 | 120 | 100 | 100 |
| 2025 | (blank) | 220 | 220 | 220 |
| 2026 | 1 | 130 | 100 | 130 |
| 2026 | 2 | 150 | 100 | 130 |
| 2026 | (blank) | 280 | 220 | 280 |
| (blank) | (blank) | 500 | 500 | 500 |
Related functions
LAST, PREVIOUS, INDEX, RUNNINGSUM.