RelativeToTarget.Numeric
Dynamic format string generator for comparison values (in value) with directional indicators. Creates format strings with visual symbols for numeric comparisons.
Syntax
DaxLib.FormatString.RelativeToTarget.Numeric (
position,
decimal_places,
symbol,
custom_prefix,
custom_suffix
)
Definition
DAX
// Dynamic format string generator for comparison values (in value)
// Returns format string with directional indicators based on parameters
(
// Position of comparison symbol
// Expects "PREFIX" or "SUFFIX"
position: STRING,
// Number of decimal places
// Expects an INT64 value from 0-9
decimal_places: INT64,
// Symbol style - number (1-9) or text:
// 1 or "ARROWS": ↑/↓
// 2 or "TRIANGLES": ▲/▼
// 3 or "PLUSMINUS": +/-
// 4 or "CHEVRONS": ˄/˅
// 5 or "GREENRED": 🟢/🔴
// 6 or "BLUEORANGE": 🔵/🟠
// 7 or "BLOCKARROWS": ⬆/⬇
// 8 or "CHECKCROSS": ✓/✗
// 9 or "NONE": no symbol
symbol: ANYVAL,
// Custom prefix text (optional)
// Enter "" to skip parameter
// Enter SELECTEDVALUE( 'Exchange Rate'[Currency Symbol] ) for dynamic currency conversion
//
// Note: Value is string-safe; no need for """"
custom_prefix: EXPR,
// Custom suffix text (optional)
// Enter "" to skip parameter
// Enter SELECTEDVALUE( 'Exchange Rate'[Currency Symbol] ) for dynamic currency conversion
// Enter " (" & FORMAT ( [PercentMeasure], "0.0%" ) & ")" to add a second value for context
//
// Note: Value is string-safe; no need for """"
custom_suffix: EXPR
) =>
VAR _BaseFormat =
DaxLib.FormatString.Component.DecimalPlaces( "#,##0", decimal_places )
VAR _Prefix =
DaxLib.FormatString.Component.MakeStringSafe ( custom_prefix )
VAR _Suffix =
DaxLib.FormatString.Component.MakeStringSafe ( custom_suffix )
VAR _PositiveSymbol =
DaxLib.FormatString.Component.Symbols ( symbol, "POSITIVE" )
VAR _NegativeSymbol =
DaxLib.FormatString.Component.Symbols ( symbol, "NEGATIVE" )
VAR _PositiveFormat =
_Prefix
& SWITCH (
position,
"PREFIX",
_PositiveSymbol & " " & _BaseFormat,
"SUFFIX",
_BaseFormat & " " & _PositiveSymbol,
_BaseFormat & " " & _PositiveSymbol
)
& _Suffix
VAR _NegativeFormat =
_Prefix
& SWITCH (
position,
"PREFIX",
_NegativeSymbol & " " & _BaseFormat,
"SUFFIX",
_BaseFormat & " " & _NegativeSymbol,
_BaseFormat & " " & _NegativeSymbol
)
& _Suffix
VAR _ZeroFormat =
_Prefix & _BaseFormat & _Suffix
RETURN
_PositiveFormat & ";" & _NegativeFormat
& ";"
& _ZeroFormat
Parameters
| Parameter | Type | Description |
|---|---|---|
position |
STRING | "PREFIX" or "SUFFIX" for symbol placement |
decimal_places |
NUMBER | Number of decimal places (0-9) |
symbol |
STRING | Symbol style: "TRIANGLES", "ARROWS", etc. |
custom_prefix |
STRING | Custom prefix text |
custom_suffix |
STRING | Custom suffix text |
Example
DaxLib.FormatString.RelativeToTarget.Numeric ( "PREFIX", 1, "ARROWS", "", "" )
Use this function to create directional formatting for numeric comparisons with symbols.
Related Functions
- RelativeToTarget.Percents - Percentage version
- Component.Symbols - Symbol selection logic
- Component.DecimalPlaces - Decimal places formatting