0
0
Power BIbi_tool~10 mins

SELECTEDVALUE and HASONEVALUE in Power BI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to return the selected product name or "Unknown" if none is selected.

Power BI
ProductName = SELECTEDVALUE('Products'[Name], [1])
Drag options to blanks, or click blank then click option'
ABLANK()
B"Unknown"
C"None"
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving the alternate value blank causes errors when multiple or no values are selected.
Using 0 instead of a string for alternate value.
2fill in blank
medium

Complete the code to check if exactly one year is selected in the 'Date' table.

Power BI
IsSingleYearSelected = HASONEVALUE([1])
Drag options to blanks, or click blank then click option'
A'Date'[Year]
B'Sales'[Year]
C'Date'[Month]
D'Products'[Year]
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column from the wrong table.
Forgetting to use single quotes around the table name.
3fill in blank
hard

Fix the error in the measure that returns the selected category or "Multiple" if more than one is selected.

Power BI
SelectedCategory = IF(HASONEVALUE('Categories'[Category]), [1], "Multiple")
Drag options to blanks, or click blank then click option'
AFIRSTNONBLANK('Categories'[Category], 1)
BVALUES('Categories'[Category])
CSELECTEDVALUE('Categories'[Category])
DDISTINCT('Categories'[Category])
Attempts:
3 left
💡 Hint
Common Mistakes
Using VALUES which returns a table, causing errors.
Using DISTINCT which also returns a table.
4fill in blank
hard

Fill both blanks to create a measure that returns the selected region or "All Regions" if none or multiple are selected.

Power BI
SelectedRegion = IF(HASONEVALUE([1]), SELECTEDVALUE([2]), "All Regions")
Drag options to blanks, or click blank then click option'
A'Regions'[Region]
B'Sales'[Region]
D'Products'[Region]
Attempts:
3 left
💡 Hint
Common Mistakes
Using different tables for HASONEVALUE and SELECTEDVALUE.
Using columns from unrelated tables.
5fill in blank
hard

Fill all three blanks to create a measure that returns the selected product or "Multiple Products" if more than one is selected, or "No Product" if none is selected.

Power BI
ProductStatus = IF(HASONEVALUE([1]), SELECTEDVALUE([2]), IF(ISBLANK(SELECTEDVALUE([3])), "No Product", "Multiple Products"))
Drag options to blanks, or click blank then click option'
A'Products'[ProductName]
D'Sales'[ProductName]
Attempts:
3 left
💡 Hint
Common Mistakes
Using different tables for the blanks.
Not handling the no selection case properly.