Popular Searches
Popular Course Categories
Popular Courses

Understanding VALUES, DISTINCT, and SELECTEDVALUE

Understanding VALUES, DISTINCT, and SELECTEDVALUE

Advanced DAX Functions and Calculations

Understanding VALUES, DISTINCT, and SELECTEDVALUE in Power BI DAX

Course: Microsoft Power BI Training

Topic: Understanding VALUES, DISTINCT, and SELECTEDVALUE in DAX

Course Link: Microsoft Power BI Training – JustAcademy

Demo Link: Register for a Free Course Demo

JustAcademy Website: Visit JustAcademy


1. Introduction to VALUES, DISTINCT, and SELECTEDVALUE

Data Analysis Expressions (DAX) is the formula language used in Power BI to create measures, calculated columns, calculated tables, and analytical calculations. Many DAX calculations depend on identifying unique values, understanding the current filter context, and retrieving a value selected by a report user.

The VALUES(), DISTINCT(), and SELECTEDVALUE() functions help solve these problems, but they do not perform exactly the same task.

  • VALUES(): Returns a table containing distinct values from a column or rows from a table, considering the current context. It can also include a special blank member when relationships contain unmatched keys.
  • DISTINCT(): Returns unique values from a column or unique rows from a table expression.
  • SELECTEDVALUE(): Returns a scalar value when exactly one distinct value exists in the current filter context; otherwise, it returns an alternate result or BLANK().

Understanding these differences helps you create reliable calculations, dynamic titles, slicer-driven reports, customer analyses, product summaries, and interactive dashboards.

2. Learning Objectives

After completing this topic, you should be able to:

  • Explain the purpose of VALUES(), DISTINCT(), and SELECTEDVALUE().
  • Understand the difference between a table result and a scalar result.
  • Write DAX expressions that retrieve distinct column values.
  • Count unique products, customers, orders, and categories.
  • Understand how filter context affects returned values.
  • Use SELECTEDVALUE() to handle single selections in slicers.
  • Set meaningful alternate results for multiple or missing selections.
  • Recognize the special blank member that VALUES() may return.
  • Combine these functions with COUNTROWS(), CALCULATE(), IF(), and other DAX functions.
  • Troubleshoot common DAX errors and incorrect totals.

3. Sample Dataset for Practice

Throughout these notes, assume a Power BI model contains a table named Sales with the following columns:

OrderID Product Category Region SalesAmount
1001 Laptop Electronics West 50000
1002 Mobile Electronics East 25000
1003 Laptop Electronics West 45000
1004 Desk Furniture North 12000
1005 Chair Furniture South 8000
1006 Mobile Electronics East 27000

In this dataset, Laptop and Mobile each appear twice. The distinct product list therefore contains four products: Laptop, Mobile, Desk, and Chair. The Region column contains West, East, North, and South.

For some examples, assume the model also has a separate Product dimension table related to the Sales table through a product key. This allows you to understand how unmatched relationship keys can affect VALUES().

4. Understanding VALUES() in DAX

4.1 What Is VALUES()?

The VALUES() function returns a one-column table of distinct values when supplied with a column name. When supplied with a table name, it returns the rows of that table. The values returned are affected by the current filter context.

For a column, duplicate values are removed. Depending on the model and relationships, a special blank member may also be included.

4.2 Syntax

VALUES(<TableNameOrColumnName>)

Parameter:

  • TableNameOrColumnName: The name of an existing table or column.

4.3 Example: Return Unique Products

Unique Products Table =
VALUES(Sales[Product])

This expression returns a table containing unique product names from the values available in the current evaluation context. It is a table expression, not a measure that directly returns one product name.

To display the values, use a table visual or use the expression inside another function that accepts a table.

4.4 Example: Count Unique Products

Unique Product Count =
COUNTROWS(
    VALUES(Sales[Product])
)

Explanation:

  1. VALUES(Sales[Product]) produces the distinct product list.
  2. COUNTROWS() counts the rows in that list.
  3. The measure returns the number of distinct product values available in the current filter context.

For the complete sample dataset, the result is 4. If a report user filters the report to Electronics, the result is 2 because only Laptop and Mobile remain.

4.5 Example: Count Unique Orders

Unique Order Count =
COUNTROWS(
    VALUES(Sales[OrderID])
)

Since each OrderID in the sample data is unique, the result is 6. In a real dataset, this measure counts distinct order IDs rather than simply counting every sales row.

4.6 Example: Get Values Under the Current Filter

Visible Regions =
VALUES(Sales[Region])

If a report user selects the West region, the returned table contains West. If East and West are selected, it contains those two values. This behavior makes VALUES() useful in calculations that respond to slicers and visual filters.

4.7 VALUES() with a Table Name

Visible Sales Rows =
VALUES(Sales)

When used with a table name, VALUES() returns the rows of that table within the applicable context. Unlike a column argument, the table result is not a single-column distinct list.

4.8 Important Behavior of VALUES()

  • It returns a table expression, not a scalar value.
  • For a column argument, duplicate values are removed.
  • Its results respond to filter context.
  • It may include a special blank member when a relationship has unmatched keys.
  • It can be used as an argument to functions such as COUNTROWS(), SUMX(), and CALCULATE().

5. Understanding DISTINCT() in DAX

5.1 What Is DISTINCT()?

The DISTINCT() function returns unique values from a column or unique rows from a table expression. It is commonly used to remove duplicates when building a list of values for a calculation.

5.2 Syntax

DISTINCT(<ColumnName>)

DISTINCT(<TableExpression>)

The argument may be a column name or a valid table expression. This is an important difference from VALUES(), which accepts a table name or column name.

5.3 Example: Return Unique Products

Distinct Products =
DISTINCT(Sales[Product])

This expression returns the distinct product names visible in the current context. With the sample dataset, the product list contains Laptop, Mobile, Desk, and Chair.

5.4 Example: Count Distinct Products

Distinct Product Count =
COUNTROWS(
    DISTINCT(Sales[Product])
)

This measure returns 4 for the complete sample dataset and 2 when the data is filtered to Electronics.

5.5 Example: Count Distinct Orders

Distinct Order Count =
COUNTROWS(
    DISTINCT(Sales[OrderID])
)

This measure counts the unique order IDs visible in the current filter context.

5.6 DISTINCT() with a Table Expression

Distinct Product and Region Pairs =
DISTINCT(
    SELECTCOLUMNS(
        Sales,
        "ProductName", Sales[Product],
        "SalesRegion", Sales[Region]
    )
)

This expression builds a table with two named columns and then removes duplicate product-region combinations. It can help analyze how many unique product and region combinations exist in the dataset.

For example, Laptop-West appears more than once in the sample data, so it is represented once in the resulting table.

5.7 Important Behavior of DISTINCT()

  • It removes duplicate values from a column.
  • It can also remove duplicate rows from a table expression.
  • Its output is a table, not a scalar.
  • Its results are affected by the context in which the expression is evaluated.
  • Unlike VALUES(), DISTINCT() does not add the special relationship-generated blank member in the same way.

6. Understanding SELECTEDVALUE() in DAX

6.1 What Is SELECTEDVALUE()?

The SELECTEDVALUE() function returns a scalar value when the specified column has exactly one distinct value in the current filter context. If there are zero or multiple distinct values, it returns an alternate result when provided; otherwise, it returns BLANK().

This function is especially useful for dynamic titles, selected-category messages, parameter slicers, conditional calculations, and interactive report experiences.

6.2 Syntax

SELECTEDVALUE(
    <ColumnName>,
    <AlternateResult>
)
  • ColumnName: An existing column, not an arbitrary expression.
  • AlternateResult: Optional. The result returned when the context contains zero or more than one distinct value. If omitted, the result is BLANK().

6.3 Example: Get the Selected Region

Selected Region =
SELECTEDVALUE(Sales[Region])

If West is the only distinct region in context, the measure returns West. If East and West are both available in the context, the measure returns BLANK(). It also returns BLANK() when no distinct value is available.

6.4 Example: Set an Alternate Result

Selected Region Message =
SELECTEDVALUE(
    Sales[Region],
    "Select one region"
)

When exactly one region is available, the measure returns its name. When there are zero or multiple distinct regions, it returns the text "Select one region".

Important: The alternate result does not only mean multiple selections. It is also used when the context has zero distinct values.

6.5 Example: Display the Selected Product

Selected Product =
SELECTEDVALUE(
    Sales[Product],
    "Multiple or no products"
)

This measure is suitable for a card visual. It shows the product name when exactly one distinct product is available and displays the alternate text otherwise.

6.6 Example: Create a Dynamic Report Title

Sales Report Title =
"Sales Report - " &
SELECTEDVALUE(
    Sales[Region],
    "All or Multiple Regions"
)

Use this measure as a dynamic title where supported, or display it in a card visual. The report title changes according to the region filter context.

For example:

  • Only West available: Sales Report - West
  • Only East available: Sales Report - East
  • Multiple regions available: Sales Report - All or Multiple Regions

Be aware that the alternate text is a label chosen by you; it does not prove that every region is included. If the distinction between no selection and multiple selections matters, use additional logic to test the context.

6.7 Example: Calculate Commission Based on a Selected Region

Total Sales =
SUM(Sales[SalesAmount])

Regional Commission =
VAR CurrentRegion =
    SELECTEDVALUE(Sales[Region])
RETURN
    SWITCH(
        CurrentRegion,
        "West", [Total Sales] * 0.10,
        "East", [Total Sales] * 0.08,
        "North", [Total Sales] * 0.07,
        "South", [Total Sales] * 0.06,
        BLANK()
    )

This example applies a different commission percentage when exactly one region is in context. If multiple regions are present, CurrentRegion is blank and the measure returns BLANK(). If the business needs a commission across multiple regions, design a calculation that evaluates each region separately and combines the results rather than assuming one selected region.

7. Key Differences Between VALUES(), DISTINCT(), and SELECTEDVALUE()

Feature VALUES() DISTINCT() SELECTEDVALUE()
Main purpose Return distinct values or table rows Return distinct values or unique rows from a table expression Retrieve one scalar value when exactly one distinct value exists
Result type Table Table Scalar
Column argument Yes Yes Yes
Table argument Table name Valid table expression No; it requires a column
Removes duplicates Yes, for column results Yes Not its purpose
Special blank member for unmatched relationships May include it Does not add it in the same way Returns a scalar based on the distinct values in context
Multiple values in context Returns a table of visible distinct values Returns a table of visible distinct values Returns alternate result or BLANK()
Typical use Count or iterate over unique values Build unique lists and table expressions Dynamic titles, slicer selections, conditional measures

8. Understanding Table Results and Scalar Results

A major source of confusion is the difference between a table and a scalar.

8.1 Table Result

VALUES(Sales[Product])

This returns a table containing distinct product values. It can be passed to functions that expect a table, such as COUNTROWS() or SUMX(). It cannot generally be used directly where a single text or numeric value is required.

8.2 Scalar Result

SELECTEDVALUE(Sales[Product], "No single product")

This returns one scalar value: the product name when exactly one distinct product is in context, or the alternate text otherwise.

8.3 Correct Use Inside a Measure

Number of Products =
COUNTROWS(
    VALUES(Sales[Product])
)

This is valid because COUNTROWS() accepts a table expression and returns a number.

8.4 Common Incorrect Pattern

-- Avoid using a table where a scalar is required
Product Label =
VALUES(Sales[Product])

This is not a suitable scalar text measure because VALUES() returns a table. If you need a single selected product name, use SELECTEDVALUE(). If you need to count or iterate over the distinct products, use VALUES() or DISTINCT() within an appropriate table-based calculation.

9. How Filter Context Affects These Functions

Filter context is the set of filters applied to a DAX expression by report slicers, visual rows and columns, page filters, report filters, relationships, and DAX functions such as CALCULATE(). These functions respond to the values available in their evaluation context.

9.1 No Region Filter

Visible Region Count =
COUNTROWS(
    VALUES(Sales[Region])
)

With all sample rows available, the result is 4.

9.2 Filter to West

When a slicer or visual filter limits Sales to West, VALUES(Sales[Region]) contains West, and the visible region count is 1.

9.3 Filter to Electronics

When the Category column is filtered to Electronics, the product list contains Laptop and Mobile. Both VALUES() and DISTINCT() return two unique product names for this example.

9.4 Example: Count Unique Products by Category

Products by Category =
COUNTROWS(
    VALUES(Sales[Product])
)

Add Sales[Category] to the rows of a table visual and this measure to its values. The measure is evaluated separately for each category.

Category Unique Products
Electronics 2
Furniture 2
Total 4

The total is recalculated in the total context. In this case, there are four distinct products overall, so the total is 4.

10. The Special Blank Member in VALUES()

10.1 What Is the Special Blank Member?

In a model with relationships, a fact table can contain a key that does not match any key in its related dimension table. When referential integrity is violated, VALUES() may include a special blank member for the dimension column so unmatched fact rows can be associated with an unknown member.

This behavior is different from simply having an empty value stored in the source data. A source blank and a relationship-generated unknown member are related concepts but are not always the same thing.

10.2 Example

Imagine a Product dimension containing these product keys:

ProductKey ProductName
1 Laptop
2 Mobile
3 Desk

Now suppose the Sales table contains a row with ProductKey 99, but the Product dimension does not contain ProductKey 99. This creates an unmatched relationship key.

In an appropriate relationship context, VALUES(Product[ProductName]) may include a blank member to represent the unmatched key.

10.3 Why This Matters

  • Unique counts from a dimension can include an unknown blank member.
  • Reports may show a blank category or product even when no visible source row appears to have a blank name.
  • Relationship quality should be checked when blank members appear unexpectedly.
  • DISTINCT() and VALUES() may differ when the special blank member is involved.

10.4 Troubleshooting Blank Members

  1. Check whether every foreign key in the fact table exists in the dimension table.
  2. Confirm that the relationship uses the intended key columns.
  3. Review data types and formatting for key mismatches.
  4. Check whether blank or invalid keys exist in the source data.
  5. Decide whether unmatched records should be corrected, excluded, or assigned to an explicit unknown member.

11. Using VALUES() and DISTINCT() with COUNTROWS()

COUNTROWS() is frequently combined with VALUES() or DISTINCT() because both functions return tables.

11.1 Count Unique Customers

Unique Customers =
COUNTROWS(
    DISTINCT(Sales[CustomerID])
)

Use this pattern when a customer can appear on multiple sales rows and you need to count unique customer IDs. Replace CustomerID with the actual column name in your model.

11.2 Count Unique Products

Unique Products =
COUNTROWS(
    VALUES(Sales[Product])
)

This is useful for counting distinct product values in the current context. If the source column contains blanks or relationships introduce a special blank member, consider how those values should be treated in the metric.

11.3 Count Unique Regions

Unique Regions =
COUNTROWS(
    DISTINCT(Sales[Region])
)

This returns the number of distinct region values visible to the calculation. If the business definition excludes blank regions, handle them explicitly rather than assuming all distinct values are valid business categories.

11.4 Compare Both Functions

Unique Products - VALUES =
COUNTROWS(
    VALUES(Sales[Product])
)

Unique Products - DISTINCT =
COUNTROWS(
    DISTINCT(Sales[Product])
)

For ordinary column values without a relationship-generated blank-member difference, the results will usually be the same. If they differ, inspect blanks, relationships, and the context in which the measures are evaluated.

12. Using SELECTEDVALUE() with IF() and SWITCH()

SELECTEDVALUE() is often combined with conditional functions to change a measure or message according to the selected value.

12.1 Conditional Message for a Selected Category

Category Message =
VAR CurrentCategory =
    SELECTEDVALUE(Sales[Category])
RETURN
    IF(
        CurrentCategory = "Electronics",
        "Electronics performance",
        "Other or multiple categories"
    )

This expression displays the electronics message when Electronics is the single value in context. Otherwise, it displays the alternate message.

12.2 SWITCH() for Multiple Regions

Region Description =
SWITCH(
    SELECTEDVALUE(Sales[Region]),
    "West", "Western Region",
    "East", "Eastern Region",
    "North", "Northern Region",
    "South", "Southern Region",
    "No single region selected"
)

SWITCH() compares the scalar returned by SELECTEDVALUE() with the listed region names. The final expression is returned if no match is found, including when the selected value is blank.

12.3 Show a Selected Sales Target

Suppose a disconnected table named Target Selector contains selectable target values. A measure can retrieve the single chosen target:

Selected Target =
SELECTEDVALUE(
    'Target Selector'[Target],
    100000
)

If one target is in context, the measure returns that target. Otherwise, it returns 100000. A disconnected table is a table without a model relationship to the other tables; it can be useful for user-controlled parameters when the measure explicitly reads its selection.

13. Practical Business Examples

13.1 Dynamic Sales Dashboard Heading

Dashboard Heading =
"Performance for " &
SELECTEDVALUE(
    Sales[Region],
    "Multiple Regions"
)

Place the measure in a card or use it in a supported dynamic-title setting. It gives the report a context-aware heading.

13.2 Unique Products Sold

Unique Products Sold =
COUNTROWS(
    VALUES(Sales[Product])
)

This metric counts distinct product names visible in the current context. If the same product is sold many times, it is counted once.

13.3 Identify Whether One Region Is in Context

Region Selection Status =
IF(
    HASONEVALUE(Sales[Region]),
    SELECTEDVALUE(Sales[Region]),
    "Choose one region"
)

HASONEVALUE() checks whether exactly one distinct value exists in the current context. In this example it is redundant because SELECTEDVALUE() can already return an alternate result, but it demonstrates how the functions relate.

13.4 Display a Selected Category in a Card

Category Card Text =
SELECTEDVALUE(
    Sales[Category],
    "Select a single category"
)

This measure is helpful when a user needs to see the active category selection without opening the slicer.

13.5 Calculate Average Sales per Distinct Product

Average Sales per Product =
DIVIDE(
    [Total Sales],
    COUNTROWS(VALUES(Sales[Product]))
)

This measure divides total sales by the number of distinct products in context. It is a simple illustration; confirm that this is the intended business definition because the result is not necessarily the same as average sales per transaction or average product-level revenue.

14. VALUES() vs. DISTINCT() vs. SELECTEDVALUE(): Choosing the Right Function

Requirement Recommended Pattern Reason
Count unique products COUNTROWS(VALUES(Sales[Product])) Counts the rows in a distinct-value table.
Build a unique list from a column DISTINCT(Sales[Product]) Returns unique values for further table calculations.
Retrieve one selected region SELECTEDVALUE(Sales[Region]) Returns a scalar when one distinct region is in context.
Display alternate text for multiple values SELECTEDVALUE(Sales[Category], "Multiple or none") Handles contexts that do not contain exactly one distinct category.
Count distinct rows from a table expression COUNTROWS(DISTINCT(table_expression)) Counts the unique rows returned by the expression.
Iterate over distinct products SUMX(VALUES(Sales[Product]), ...) Evaluates an expression for each distinct product row.
Investigate an unknown relationship member VALUES(Dimension[Key]) Can expose the special blank member caused by unmatched relationship keys.

15. Common Errors and Troubleshooting

15.1 Error: A Table Result Is Used Where a Scalar Is Required

Problem: Using VALUES() directly as though it always returns one text or numeric value.

Solution: Use SELECTEDVALUE() when a single scalar is required, or pass VALUES() into a function that accepts a table.

Selected Product =
SELECTEDVALUE(
    Sales[Product],
    "Multiple or no products"
)

15.2 Unexpected BLANK() from SELECTEDVALUE()

Possible causes:

  • More than one distinct value exists in the current context.
  • No distinct value is available in the current context.
  • A visual total evaluates over several values instead of one.
  • Relationships or other filters remove the expected rows.

Solution: Supply an alternate result, inspect the current filter context, and verify that the measure is evaluated at the intended level of detail.

Selected Product Label =
SELECTEDVALUE(
    Sales[Product],
    "Select one product"
)

15.3 VALUES() and DISTINCT() Return Different Counts

Possible cause: A relationship may introduce a special blank member for unmatched keys, or the expressions may be evaluated in different contexts.

Solution: Compare the actual returned values, inspect relationships, and validate the model's key columns. Do not assume the two functions are interchangeable in every model.

15.4 Incorrect Unique Counts

Possible causes:

  • The calculation uses the wrong column.
  • Blank values are included in the business metric unexpectedly.
  • The visual has filters that change the result.
  • Rows represent transactions, but the calculation is intended to count distinct entities.

Solution: Confirm the business definition, check the column's data quality, and validate the measure against a small sample of records.

15.5 Unexpected Totals

In Power BI, a measure is generally recalculated in the total's filter context. The total for a distinct-count measure may therefore differ from the sum of the individual row results when the same entity appears in multiple groups.

For example, if a product appears in both East and West, it may be counted once in each region but only once in the overall distinct product count.

15.6 No Value Appears in a Dynamic Title

Check that the measure references the correct column and that the current report context contains exactly one distinct value. Also confirm that the visual or title property is configured to use the measure.

16. Best Practices

  • Use SELECTEDVALUE() when you need a single value from a column and want predictable behavior for multiple or missing values.
  • Use VALUES() when a table of distinct values is needed for counting, filtering, or iteration.
  • Use DISTINCT() when you need unique values from a column or unique rows from a table expression.
  • Remember that VALUES() and DISTINCT() return tables, while SELECTEDVALUE() returns a scalar.
  • Provide a meaningful alternate result in SELECTEDVALUE() when a blank result would confuse report users.
  • Check the total-row context before interpreting a measure's result.
  • Investigate blank members and unmatched keys when VALUES() returns an unexpected blank.
  • Use descriptive measure names, such as Unique Product Count or Selected Region.
  • Test measures with no filter, a single selection, multiple selections, and a context with no matching rows.
  • Validate unique-count calculations against sample data before publishing a report.
  • Keep the business definition clear: unique orders, unique products, unique customers, and unique combinations are different metrics.

17. Practice Exercises

Exercise 1: Count Unique Products

Create a measure that counts the unique product names in the Sales table using VALUES().

Unique Product Count =
COUNTROWS(
    VALUES(Sales[Product])
)

Expected result: 4 for the complete sample dataset.

Exercise 2: Count Distinct Regions

Create a measure using DISTINCT() to count unique regions.

Unique Region Count =
COUNTROWS(
    DISTINCT(Sales[Region])
)

Expected result: 4 for the complete sample dataset.

Exercise 3: Display the Selected Region

Create a measure that returns the selected region or displays an alternate message.

Selected Region =
SELECTEDVALUE(
    Sales[Region],
    "Select one region"
)

Test it with West selected, with East and West selected, and with a context that contains no region values.

Exercise 4: Create a Dynamic Category Title

Create a measure that displays the selected category in a heading.

Category Title =
"Category Analysis: " &
SELECTEDVALUE(
    Sales[Category],
    "Multiple or no categories"
)

Exercise 5: Compare VALUES() and DISTINCT()

Create two measures that count distinct product names, one using VALUES() and one using DISTINCT(). Compare their results with and without filters. If the counts differ, investigate blanks and relationships.

18. Mini Project: Interactive Sales Summary Dashboard

Project objective: Build an interactive sales summary page using VALUES(), DISTINCT(), and SELECTEDVALUE().

Step 1: Prepare the Data

  • Load the Sales table into Power BI Desktop.
  • Confirm data types and check for duplicate or blank keys.
  • Review relationships between fact and dimension tables.

Step 2: Create the Measures

Total Sales =
SUM(Sales[SalesAmount])

Unique Product Count =
COUNTROWS(
    VALUES(Sales[Product])
)

Unique Region Count =
COUNTROWS(
    DISTINCT(Sales[Region])
)

Selected Region =
SELECTEDVALUE(
    Sales[Region],
    "Multiple or no regions"
)

Selected Category =
SELECTEDVALUE(
    Sales[Category],
    "Multiple or no categories"
)

Sales Page Title =
"Sales Overview - " &
SELECTEDVALUE(
    Sales[Region],
    "All or Multiple Regions"
)

Step 3: Build the Report Page

  1. Add a card for Total Sales.
  2. Add a card for Unique Product Count.
  3. Add a card for Unique Region Count.
  4. Add a slicer for Region.
  5. Add a slicer for Category.
  6. Display Selected Region and Selected Category in card visuals.
  7. Use Sales Page Title as a supported dynamic visual title or display it in a separate card.

Step 4: Test the Dashboard

  • Select one region and verify that the selected-region message changes.
  • Select multiple regions and confirm that the alternate message appears.
  • Filter to Electronics and verify that the unique product count becomes 2.
  • Clear the filters and check the overall results.
  • Inspect totals and investigate any unexpected blank values.

Expected Learning Outcome

By completing this project, you will understand how distinct-value tables and scalar selection functions work together to make Power BI reports interactive and responsive to filter context.

19. Interview Questions and Answers

Q1. What does VALUES() do in DAX?

Answer: VALUES() returns distinct values from a column or rows from a table, depending on its argument. Its output is affected by filter context, and it may include a special blank member when relationship keys do not match.

Q2. What does DISTINCT() do in DAX?

Answer: DISTINCT() returns unique values from a column or unique rows from a table expression.

Q3. What is SELECTEDVALUE() used for?

Answer: SELECTEDVALUE() returns a scalar value when exactly one distinct value exists in the current filter context. Otherwise, it returns the alternate result or BLANK().

Q4. What is the main difference between VALUES() and SELECTEDVALUE()?

Answer: VALUES() returns a table, whereas SELECTEDVALUE() returns a scalar value when there is exactly one distinct value in context.

Q5. Are VALUES() and DISTINCT() always identical?

Answer: No. For a column argument they usually return the same distinct values, but VALUES() can include a special blank member when referential integrity is violated. DISTINCT() also supports a valid table expression as its argument.

Q6. What happens when SELECTEDVALUE() has multiple values in context?

Answer: It returns the specified alternate result. If no alternate result is supplied, it returns BLANK().

Q7. Can VALUES() be used to count unique products?

Answer: Yes. Use COUNTROWS(VALUES(Sales[Product])) to count distinct product values in the current context.

Q8. Why might a distinct count include a blank member?

Answer: The source column may contain blanks, or VALUES() may include a special blank member caused by unmatched keys in a relationship. The model and data should be inspected to identify the cause.

Q9. How can SELECTEDVALUE() help create dynamic titles?

Answer: It retrieves the single selected category, product, or region and combines it with text. An alternate result can be displayed when multiple or no distinct values are available.

Q10. Why can a distinct-count total differ from the sum of the displayed rows?

Answer: A distinct-count measure is recalculated in the total context. If the same entity appears in multiple groups, it can be counted in several rows but only once in the overall total.

Q11. Can SELECTEDVALUE() accept an expression instead of a column?

Answer: No. Its first argument must be an existing column name. If you need a more complex table expression, first design the appropriate DAX logic to obtain the required scalar.

Q12. What should you check when SELECTEDVALUE() returns BLANK() unexpectedly?

Answer: Check whether the current context contains zero or multiple distinct values, review the visual's total context, and inspect slicers, relationships, and filters.

20. Quick Revision Notes

  • VALUES(): Returns a table of distinct column values or rows from a table.
  • DISTINCT(): Returns unique column values or unique rows from a table expression.
  • SELECTEDVALUE(): Returns one scalar when exactly one distinct value exists in context.
  • Default alternate result: BLANK() when SELECTEDVALUE() has no alternate result and the context does not contain exactly one distinct value.
  • Count unique values: Use COUNTROWS(VALUES(Column)) or COUNTROWS(DISTINCT(Column)), depending on the requirement.
  • Dynamic titles: Use SELECTEDVALUE() with text concatenation and an appropriate alternate result.
  • Filter context: Determines which values are visible to the expression.
  • Relationship blank member: VALUES() may include a special blank member for unmatched relationship keys.
  • Table versus scalar: VALUES() and DISTINCT() return tables; SELECTEDVALUE() returns a scalar.
  • Totals: Measures are recalculated in the total context, so distinct-count totals may not equal the sum of visible rows.

21. Additional Learning Resources

22. Conclusion

VALUES(), DISTINCT(), and SELECTEDVALUE() are essential DAX functions for working with unique values and filter context in Power BI. VALUES() and DISTINCT() help create tables of unique values, while SELECTEDVALUE() retrieves a single scalar value when exactly one distinct value is available.

Use VALUES() or DISTINCT() when your calculation needs a list of unique values. Use SELECTEDVALUE() when a measure needs the value of a single selected category, product, or region. Always test the calculation under single selections, multiple selections, no matching rows, and total rows to ensure the report behaves as intended.

Practice these functions with real datasets and combine them with COUNTROWS(), CALCULATE(), IF(), SWITCH(), and other DAX functions to build accurate, interactive Power BI reports.

whatsapp