Power BI visual DAX opens up a new way to create powerful, row‑level calculations directly inside table and matrix visuals without cluttering your model with extra measures. In this post, you’ll learn how to use visual calculations to add row numbers, handle totals, create moving averages, and apply advanced logic beyond the standard dropdown options.
Turning On Visual Calculations
Before you begin, make sure visual calculations are enabled:
- Go to File > Options and settings > Options
- Open the Preview features tab
- Turn on Visual calculations
- Restart Power BI Desktop if required
Once enabled, you’ll see a new Visual calculation button in the Home tab when a visual is selected. This opens the editor to define a new visual calculation.
Trick 1 Adding Row Numbers to a Matrix or Table
Often, you want a simple index like 1, 2, 3 for rows. Instead of building complex measures, use the built‑in ROW_NUMBER() function.
- Select your matrix or table visual
- Click Visual calculation > New
- Name the calculation (e.g.,
Index) - Enter:
= ROW_NUMBER()
Now the visual displays sequential row numbers.
Resetting Per Group
If you want the row numbers to reset for each group (e.g., each year), provide a grouping column:
= ROW_NUMBER([Year])
This restarts the count with each year.
Formatting the Index
Use column formatting options to show integers (no decimals) for clean display.
Trick 2 Handling Totals with IS_AT_LEVEL

Sometimes the totals row shouldn’t show row numbers or summaries. The IS_AT_LEVEL() function comes in handy:
IF(
IS_AT_LEVEL([Quarter]),
ROW_NUMBER([Year]),
BLANK()
)
This shows the row number only when the context is at the Quarter level hiding it at total rows.
Trick 3 Simple Moving Averages
Calculating moving averages can be complex with DAX measures. With visual calculations:
- Create a new visual calculation called
MOV AVG - Use the
MOVING_AVERAGE()function:= MOVING_AVERAGE([Total Sales], 2)
This calculates a 2‑period moving average.
Excluding Current Period
To average only previous values:
= MOVING_AVERAGE([Total Sales], 2, FALSE)
Resetting Averages by Year
To reset the window each year:
= MOVING_AVERAGE([Total Sales], 2, TRUE, [Year])
This ensures rolling averages don’t mix data across years.
Trick 4 Using the ROWS() Operator
The ROWS() operator references the entire set of visual rows (excluding totals). This is useful if you want to compute something like the overall maximum across the visible column.
Example: Maximum Value in Visual
= MAXX(ROWS(), [Total Sales])
This gives the maximum value seen in the current visual segment.
Trick 5 Filtering Within ROWS()

Want the maximum sales within a specific year?
- Inside the visual calculation, define a variable to capture the selected year:
VAR currentYear = SELECTEDVALUE([Year]) - Then filter:
RETURN MAXX( FILTER( ROWS(), [Year] = currentYear ), [Total Sales] )
This counts only rows where the year matches, then evaluates the maximum.
Trick 6 First and Last Values
Visual calculations also let you pull edge values like first or last value across a group.
First Value in Table
= FIRST([Total Sales])
This repeats the first value across the table.
Group Reset (e.g., by Channel)
To reset by group:
= FIRST([Total Sales], [Channel])
Or by column position:
= FIRST([Total Sales], 2)
Why These Tricks Matter
Visual calculations let you:
- Add row computations without writing additional DAX measures
- Customize outputs for each level of your visual
- Build advanced analytics (rolling metrics, first/last values)
- Improve report readability
For deeper learning on visuals, DAX, and data modelling, explore professional courses
By using Power BI visual DAX, you can perform advanced calculations at the visual level, keeping your data model cleaner while still delivering highly customized analytics.
Conclusion
Visual calculations in Power BI go far beyond simple summaries. From adding dynamic row numbers and moving averages to powerful operators like ROWS() and context controls with IS_AT_LEVEL(), these techniques unlock advanced analytics without bloating your model with measures.





