“Exploring Power BI Visual Calculations”

Introduction

In the February 2024 release of Microsoft’s Power BI Desktop, a groundbreaking approach to calculations was introduced: Visual Calculations. Representing a DAX (Data Analysis Expressions) calculation, Visual Calculations are defined and executed directly on a visual element. This innovative method allows referencing of any data within the visual, encompassing columns, measures, or other visual calculations. The adoption of Visual Calculations not only streamlines DAX complexity but also facilitates easier maintenance, ultimately contributing to enhanced performance.

How does Visual Calculation differ from other calculation options?

  1. Visual calculations are stored on the visual, not in the model.
  2. Visual calculations can only refer to elements present in the visual.
  3. They combine the simplicity of context from calculated columns with the on-demand calculation flexibility from measures
  4. In contrast to measures, visual calculations operate on aggregated data, often leading to better performance.
AspectMeasureVisual calculation
LanguageDAXDAX
ContextFilterVisual
Stored inModelVisual
Computed atOn-demandOn-demand
Applies User InteractionYesYes

How to use Visual Calculations?

To leverage visual calculations, enable this feature in Options and Settings > Options > Preview features. Simply choose ‘Visual calculations’ and click ‘OK.’ Remember, the activation of visual calculations takes effect upon restarting the Power BI Desktop.

To add a visual calculation, first select a visual. Then, select the New Calculation button in the ribbon

The visual calculations window opens in Edit mode. The Edit mode screen consists of three major sections:

  1. Visual Preview: shows a preview of the visual that we are working with
  2. A formula bar: we can write visual calculation Dax expression
  3. The visual matrix: displays the results of visual calculations in table format.

In the formula bar, we can write a visual query in DAX. For example, if we want to find the total profit from the below visual using [Total Expense] and [Total Sales] by year, it would be easier like below.

We can make use of this visual calculation [Total Profit] for writing another calculation in the same visual.

However, it is not possible to use other measures or columns that are not used on the respective visual. Another interesting fact is that we can hide fields from visuals in the edit mode. Hiding fields does not eliminate them from the visual or the visual matrix, allowing your visual calculations to retain references and functionality. For example, if we want to hide [Total Sales] and [Total Expenses] from the visual, just hide them in the edit mode like below.

This new feature supports third-party visuals as well. Just tried to replicate the same on a bullet chart by OKVIZ.

Using Templates

To simplify the creation of common calculations, visual calculations offer templates. Access these templates by clicking the template button fx and selecting the desired template to use. Using the templates we can write complex DAX queries easily.

Visual calculations support the utilization of numerous existing DAX functions. However, it’s important to note that, due to their operation within the visual matrix, functions dependent on model relationships, such as USERELATIONSHIP, RELATED, or RELATED TABLE, are not accessible in this context.

Considerations and Limitations

When writing this blog in Feb 2024, the below features are not available.

FeatureDescription
Filters on visualWe can’t filter on visuals
PersonalizationPersonalization of visual calculations or hidden fields isn’t available
Publish to webWe can’t use the Publish to web functionality with reports that use visual calculations or hidden field
Custom Format StringsWe can’t set built-in or custom format strings on visual calculations.
Conditional FormattingWe can’t apply conditional formatting on visual calculations.
Data categoriesWe can’t set data categories on visual calculations.
AggregationsWe can’t change aggregations on visual calculations.
Field ParametersWe can’t use field parameters with visual calculations.
Drill throughWe can’t use the see records drill-through functionality with visuals that use visual calculations or hidden fields.
Power BI serviceEditing visual calculations or hidden fields in the Power BI service is not supported

Observations

Not all visual types support visual calculations. Only the below set of visuals is supported.

  1. Visual Calculations support both implicit measures and explicit measures
  2. It supports the Comment Line

3. Hide from visual is a new feature

4. Auto Correction is not supported yet.

Author: Team PowerBI

https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-visual-calculations-overview
https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-calculations-options

Leave a Reply

Your email address will not be published.