Skip to content

Commit fc9700b

Browse files
author
Owen Duncan
authored
Merge pull request #95 from kyleamueller/patch-1
Update selectedmeasure-function-dax.md
2 parents f8ce070 + 27f9ec9 commit fc9700b

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

query-languages/dax/selectedmeasure-function-dax.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ recommendations: false
1313
---
1414
# SELECTEDMEASURE
1515

16-
Used by expressions for calculation items to reference the measure that is in context.
16+
Used by expressions for calculation items or dynamic format strings to reference the measure that is in context.
1717

1818
## Syntax
1919

@@ -27,11 +27,11 @@ None
2727

2828
## Return value
2929

30-
A reference to the measure that is currently in context when the calculation item is evaluated.
30+
A reference to the measure that is currently in context when the calculation item or format string is evaluated.
3131

3232
## Remarks
3333

34-
- Can only be referenced in the expression for a calculation item.
34+
- Can only be referenced in the expression for a calculation item or format string.
3535

3636
- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)]
3737

@@ -42,6 +42,17 @@ The following calculation item expression calculates the year-to-date for whatev
4242
```dax
4343
CALCULATE(SELECTEDMEASURE(), DATESYTD(DimDate[Date]))
4444
```
45+
46+
The following expression can be used to dynamically adjust the format string of a measure based upon whether a value is the hundreds, thousands, or millions.
47+
48+
```dax
49+
SWITCH(
50+
TRUE(),
51+
SELECTEDMEASURE() < 1000,"$#,##0", //Values less than 1000 have no text after them
52+
SELECTEDMEASURE() < 1000000, "$#,##0,.0 K", //Values between 1000 and 1000000 are formatted as #.## K
53+
"$#,##0,,.0 M" //Values greater than 1000000 are formatted as #.## M
54+
)
55+
```
4556

4657
## See also
4758

0 commit comments

Comments
 (0)