Power BI’s SELECTEDVALUE() function

Comment utiliser la fonction SELECTEDVALUE sur Power BI

In dashboard design, one of the issues that always comes up is how to create dynamic page or chart titles without having to do so statically, so that the title changes according to the filter selected by the user. This is where the SELECTEDVALUE() function comes into its own.

The SELECTEDVALUE() function in DAX is used to obtain a single value selected in a given context. If several values are selected, it returns an alternative value specified by the user (by default, it returns BLANK()). This function is very useful in Power BI for scenarios such as creating measures dependent on user selection in a slicer.

Syntax

SELECTEDVALUE

  • <column>: The column in which you want to obtain the selected single value.
  • [alternateResult] (optional): The value to be returned if more than one value is selected or if no value is selected. If this parameter is not supplied, BLANK() is returned by default.

Examples

  • Get a single value selected in a slicer:

Suppose you have a Calendar table (Tab_Calendar) with a Tab_Calendar[Year] column. You want to create a measure that displays the year selected by the user in a slicer.

SELECTEDVALUE

This measurement returns the selected year if only one year is selected. If several years are selected, it returns “Several Years Selected”.

  • Use in conditional measures :

You can also use SELECTEDVALUE to create conditional measures. For example, you may wish to display total sales only for the selected category in a slicer:

SELECTED VALUE

In this example, if no category is selected, the measure displays total sales. Otherwise, it calculates sales for the selected category.

  • Combination with other DAX functions :

The SELECTEDVALUE function can be combined with other DAX functions for more complex analyses. For example, to calculate the percentage of sales per selected category:

SELECTEDVALUE

Case studies

  • Dynamic filters: SELECTEDVALUE is particularly useful for dynamic reports where users can select different criteria in slicers to view specific results.
  • Conditional visualizations: Use SELECTEDVALUE to adapt visualizations to user selections, for example, by displaying dynamic titles or annotations in your charts.

By using SELECTEDVALUE, you can make your Power BI reports more interactive and personalized according to user selections, offering a richer, more intuitive data visualization experience.

Leave A Comment

Cart

No products in the cart.

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare