Bird
Raised Fist0
Power BIbi_tool~20 mins

SELECTEDVALUE and HASONEVALUE in Power BI - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
SELECTEDVALUE and HASONEVALUE Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ dax_lod_result
intermediate
2:00remaining
Understanding SELECTEDVALUE with multiple selections

Given a slicer on the 'ProductCategory' column with multiple categories selected, what will the following DAX measure return?

Selected Category = SELECTEDVALUE('Product'[ProductCategory], "Multiple")
Power BI
Selected Category = SELECTEDVALUE('Product'[ProductCategory], "Multiple")
A"Multiple"
BThe first selected category
CBlank
DError
Attempts:
2 left
💡 Hint

Think about what SELECTEDVALUE returns when more than one value is selected.

❓ dax_lod_result
intermediate
1:30remaining
Using HASONEVALUE to check filter context

What will the following DAX expression return when the report is filtered to exactly one 'Region'?

Is Single Region = HASONEVALUE('Sales'[Region])
Power BI
Is Single Region = HASONEVALUE('Sales'[Region])
ABlank
BFALSE
CTRUE
DError
Attempts:
2 left
💡 Hint

HASONEVALUE returns TRUE only if exactly one distinct value is in the current filter context.

❓ visualization
advanced
2:30remaining
Visualizing dynamic titles with SELECTEDVALUE and HASONEVALUE

You want to create a dynamic title for a report page that shows the selected 'Year' if only one year is selected, or "Multiple Years" if more than one year is selected. Which DAX measure correctly achieves this?

ATitle = IF(COUNTROWS(VALUES('Date'[Year])) > 1, "Multiple Years", SELECTEDVALUE('Date'[Year]))
BTitle = SELECTEDVALUE('Date'[Year], "Multiple Years")
CTitle = IF(HASONEVALUE('Date'[Year]), "Multiple Years", SELECTEDVALUE('Date'[Year]))
DTitle = IF(HASONEVALUE('Date'[Year]), SELECTEDVALUE('Date'[Year]), "Multiple Years")
Attempts:
2 left
💡 Hint

HASONEVALUE checks if exactly one value is selected. SELECTEDVALUE returns that value or alternate.

🔧 Formula Fix
advanced
2:00remaining
Debugging unexpected blank result with SELECTEDVALUE

A measure uses SELECTEDVALUE to get the selected 'Customer'[Name], but it returns blank even when one customer is selected. What is the most likely cause?

Power BI
Selected Customer = SELECTEDVALUE('Customer'[Name])
AThe 'Customer'[Name] column has duplicate values causing SELECTEDVALUE to return blank
BThe filter context includes multiple customers, so SELECTEDVALUE returns blank
CThe 'Customer'[Name] column is not loaded in the data model
DThe measure syntax is incorrect and causes a runtime error
Attempts:
2 left
💡 Hint

SELECTEDVALUE returns blank (no alternate specified) if the filter context has more than one distinct value for the column.

🧠 Conceptual
expert
3:00remaining
Choosing between SELECTEDVALUE and HASONEVALUE in complex filters

In a report with multiple slicers and complex filter context, which statement best describes the difference between SELECTEDVALUE and HASONEVALUE?

ASELECTEDVALUE returns the single selected value or alternate; HASONEVALUE returns TRUE if exactly one distinct value exists in filter context
BSELECTEDVALUE returns TRUE or FALSE; HASONEVALUE returns the selected value or alternate
CSELECTEDVALUE and HASONEVALUE always return the same result in any filter context
DSELECTEDVALUE returns all selected values concatenated; HASONEVALUE returns the count of selected values
Attempts:
2 left
💡 Hint

Think about what each function returns and their purpose in filter context evaluation.

Practice

(1/5)
1. What does the SELECTEDVALUE function do in Power BI?
easy
A. Filters the data to only one selected value
B. Checks if exactly one value is selected
C. Returns all selected values as a list
D. Returns the single selected value or a default if multiple values are selected

Solution

  1. Step 1: Understand the purpose of SELECTEDVALUE

    SELECTEDVALUE returns a single value if only one is selected; otherwise, it returns a default or blank.
  2. Step 2: Compare with other options

    HASONEVALUE checks selection count, not returning the value itself; other options describe different behaviors.
  3. Final Answer:

    Returns the single selected value or a default if multiple values are selected -> Option D
  4. Quick Check:

    SELECTEDVALUE = single value or default [OK]
Hint: SELECTEDVALUE gives one value or default if many selected [OK]
Common Mistakes:
  • Confusing SELECTEDVALUE with HASONEVALUE
  • Thinking SELECTEDVALUE returns all selected values
  • Assuming SELECTEDVALUE filters data
2. Which of the following is the correct syntax for using HASONEVALUE in a DAX measure?
easy
A. HASONEVALUE = ColumnName
B. HASONEVALUE[ColumnName]
C. HASONEVALUE(ColumnName)
D. HASONEVALUE(ColumnName, DefaultValue)

Solution

  1. Step 1: Recall HASONEVALUE syntax

    HASONEVALUE takes a single column as argument to check if exactly one value is selected.
  2. Step 2: Eliminate incorrect syntax

    Options A, C, and D do not follow correct function call syntax or add invalid parameters.
  3. Final Answer:

    HASONEVALUE(ColumnName) -> Option C
  4. Quick Check:

    HASONEVALUE(Column) syntax correct [OK]
Hint: HASONEVALUE takes one column as argument in parentheses [OK]
Common Mistakes:
  • Using equal sign instead of parentheses
  • Adding extra parameters to HASONEVALUE
  • Using square brackets incorrectly
3. Given the following DAX measure:
Selected Product = SELECTEDVALUE('Products'[ProductName], "Multiple")

If the user selects exactly one product named "Chair", what will the measure return?
medium
A. "Chair"
B. "Multiple"
C. Blank
D. Error

Solution

  1. Step 1: Understand SELECTEDVALUE behavior with one selection

    When exactly one value is selected, SELECTEDVALUE returns that value, here "Chair".
  2. Step 2: Consider the default value

    The default "Multiple" is returned only if multiple or no values are selected, which is not the case here.
  3. Final Answer:

    "Chair" -> Option A
  4. Quick Check:

    One value selected = returns that value [OK]
Hint: One selected value returns it, else default [OK]
Common Mistakes:
  • Assuming default value returns even with one selection
  • Confusing blank with default
  • Expecting error on multiple selections
4. You wrote this DAX measure:
IsSingleCategory = IF(HASONEVALUE('Sales'[Category]), SELECTEDVALUE('Sales'[Category]), "Multiple")

But it always returns "Multiple" even when one category is selected. What is the likely problem?
medium
A. The HASONEVALUE function is used incorrectly without a filter context
B. SELECTEDVALUE cannot be used inside IF statements
C. The column name 'Category' is misspelled
D. The measure lacks a default value in SELECTEDVALUE

Solution

  1. Step 1: Analyze HASONEVALUE usage

    HASONEVALUE depends on filter context; if no filter is applied, it returns FALSE even if one value exists.
  2. Step 2: Understand why measure returns "Multiple"

    Without proper filter context, HASONEVALUE returns FALSE, so IF returns "Multiple" always.
  3. Final Answer:

    The HASONEVALUE function is used incorrectly without a filter context -> Option A
  4. Quick Check:

    HASONEVALUE needs filter context to work [OK]
Hint: HASONEVALUE needs filter context to return TRUE [OK]
Common Mistakes:
  • Assuming SELECTEDVALUE can't be inside IF
  • Ignoring filter context importance
  • Not checking column spelling
5. You want to create a measure that shows the selected product name if exactly one product is selected, otherwise shows "Multiple Products". Which DAX expression correctly achieves this?
hard
A. Product Selected = IF(SELECTEDVALUE('Products'[ProductName]), HASONEVALUE('Products'[ProductName]), "Multiple Products")
B. Product Selected = IF(HASONEVALUE('Products'[ProductName]), SELECTEDVALUE('Products'[ProductName]), "Multiple Products")
C. Product Selected = SELECTEDVALUE('Products'[ProductName], HASONEVALUE('Products'[ProductName]))
D. Product Selected = HASONEVALUE('Products'[ProductName]) & SELECTEDVALUE('Products'[ProductName])

Solution

  1. Step 1: Understand the requirement

    Show product name if exactly one selected; else show "Multiple Products".
  2. Step 2: Evaluate each option

    Product Selected = IF(HASONEVALUE('Products'[ProductName]), SELECTEDVALUE('Products'[ProductName]), "Multiple Products") uses HASONEVALUE to check selection count and SELECTEDVALUE to get the name, with fallback text. Others misuse functions or syntax.
  3. Final Answer:

    Product Selected = IF(HASONEVALUE('Products'[ProductName]), SELECTEDVALUE('Products'[ProductName]), "Multiple Products") -> Option B
  4. Quick Check:

    HASONEVALUE + SELECTEDVALUE with IF = correct pattern [OK]
Hint: Use IF with HASONEVALUE and SELECTEDVALUE for conditional display [OK]
Common Mistakes:
  • Passing HASONEVALUE as default to SELECTEDVALUE
  • Using SELECTEDVALUE as condition in IF
  • Concatenating HASONEVALUE and SELECTEDVALUE incorrectly
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard