Daily DAX : Day 418 ISSELECTEDMEASURE
Power BI DAX: ISSELECTEDMEASURE() Function
Introduced in: December 2023 Update (Calculation Groups 2.0)
What is ISSELECTEDMEASURE()?
The ISSELECTEDMEASURE() function checks whether one or more specified measures are currently selected in a calculation item (inside a calculation group).
Syntax
ISSELECTEDMEASURE ( <measure1> [, <measure2>, ...] )
Return Value
TRUE – if at least one of the listed measures is the one currently being evaluated by the calculation item.
FALSE – otherwise.
Use Case: Dynamic Formatting or Logic Based on Selected Measure
This function is extremely useful when you want a calculation item to behave differently depending on which base measure the user has selected in a visual.
Real-World Example
Imagine you have a calculation group called "Dynamic Format" with one calculation item "Color Logic" that changes the font color of values:
- Red if measure is Sales Amount
- Blue if measure is Profit
- Black for all others
DAX Code in the Calculation Item "Color Logic"
SWITCH (
TRUE(),
ISSELECTEDMEASURE ( [Sales Amount] ), "Red",
ISSELECTEDMEASURE ( [Profit] ), "Blue",
"Black" -- default
)
This returns a color name that can be used in Dynamic Format String or conditional formatting.
Common Use Cases
| Use Case | Description |
|---|---|
| Dynamic Format Strings | Show % sign only when certain measures are selected |
| Conditional Units (K, M, B) | Show values in thousands only for large measures |
| Different Decimal Places | 0 decimals for counts, 2 for currency measures |
| Custom Tooltips or Logic | Apply different calculation logic only to specific measures |
Important Notes
- Only works inside calculation items of a calculation group.
- You can list multiple measures:
ISSELECTEDMEASURE([Sales], [Budget], [Forecast]) - Works with measures from any table (including implicit measures).
- Extremely powerful when combined with
SELECTEDMEASURE(),SELECTEDMEASURENAME(), and dynamic format strings.
Summary: ISSELECTEDMEASURE() is the key function that enables truly dynamic, measure-aware formatting and logic in modern Power BI calculation groups.
Comments
Post a Comment