Basic.Temperature

Temperature formatting with Celsius/Fahrenheit scale and decimal places.

Syntax

DaxLib.FormatString.Basic.Temperature ( scale, decimal_places )

Definition

DAX
// Format temperature values with unit symbols
// Returns formatted temperature like "23.5°C", "75°F"
//
// WARNING: Doesn't convert units
(
    // Temperature unit: "C" for Celsius, "F" for Fahrenheit
    unit: STRING,

    // Number of decimal places (0-2)
    decimal_places: INT64
) =>
    VAR _Unit =
        SWITCH (
            UPPER( unit ),
            "C", "°C",
            "F", "°F",
            "°"
        )

    VAR _Format =
        DaxLib.FormatString.Component.DecimalPlaces (
            "#,##0",
            decimal_places
        )
        & " " & _Unit

    RETURN
        _Format

Parameters

Parameter Type Description
scale STRING "C" for Celsius, "F" for Fahrenheit
decimal_places NUMBER Number of decimal places

Example

DaxLib.FormatString.Basic.Temperature ( "C", 1 )

Use this function in a measure's formatStringDefinition to apply temperature formatting with Celsius scale and 1 decimal place.

Related Functions