Forum Discussion

matthias_vc's avatar
matthias_vc
Frequent Visitor
11 months ago
Solved

Custom Number Format in thousands with decimals

Hi, When assigning a custom number format I thought it would work exactly like number formats in Excel. (I am from Belgium) I have this number: 644.167.299,59 that I would like to format so takes l...
  • danextian's avatar
    11 months ago

    Hi matthias_vc 

    Please try this dynamic format string below:

    VAR _v = ABS ( [Amt] )   -- replace with your measure
    RETURN
    SWITCH (
        TRUE(),
        _v = 0,                          "0",
        _v < 1,                          "#.###",        -- e.g. 0.123
        _v < 10,                         "0.0",          -- e.g. 1.2
        _v < 100,                        "0.##",         -- e.g. 12.3
        _v < 1000,                       "0.00",         -- e.g. 123.45
        _v < 1000000,                    "#,##0,.0K",    -- thousands → 1.2K
        _v < 1000000000,                 "#,##0,,.0M",   -- millions  → 1.2M
        _v < 1000000000000,              "#,##0,,,.0Bn", -- billions  → 1.2Bn
        "#,###"                                         -- fallback
    )

    For this to work on visuals other than a table or a matrix, ensure that the display units of X-axis is set to none

    Please see the attached pbix.