Forum Discussion

sks2701's avatar
sks2701
Helper III
5 years ago
Solved

how to format a number column

Hi- I have a revenue column in my data set - I would like to format this in the short format in the table view so for example if the cokumn contains 2140100000 as value in the table i want to format ...
  • Icey's avatar
    Icey
    5 years ago

    Hi sks2701 ,

     

    If "[Total Funding Amount Currency (in USD)]" is a measure, it is unnecessary to use MIN() function. Just try this:

    Measure =
    VAR thisnumber = [Total Funding Amount Currency (in USD)]
    RETURN
        IF (
            thisnumber < 1000000000,
            FORMAT ( thisnumber, "###,,.0M" ),
            FORMAT ( thisnumber, "###,,,.0B" )
        )
    

     

    Or this:

    Measure =
    VAR SafeLog =
        IFERROR (
            ABS ( INT ( LOG ( ABS ( [Total Funding Amount Currency (in USD)] ), 1000 ) ) ),
            0
        )
    VAR dp = 1
    RETURN
        ROUND (
            DIVIDE ( [Total Funding Amount Currency (in USD)], 1000 ^ SafeLog ),
            dp
        )
            & SWITCH ( Safelog, 1, "K", 2, "M", 3, "bn", 4, "tn" )
    

     

    If "[Total Funding Amount Currency (in USD)]" is a column, it is necessary to use function like SUM(), MIN(), etc.. Try this:

    Measure =
    VAR thisnumber =
        SUM ( [Total Funding Amount Currency (in USD)] )
    RETURN
        IF (
            thisnumber < 1000000000,
            FORMAT ( thisnumber, "###,,.0M" ),
            FORMAT ( thisnumber, "###,,,.0B" )
        )
    

     

    Or this:

    Measure =
    VAR SafeLog =
        IFERROR (
            ABS (
                INT ( LOG ( ABS ( SUM ( [Total Funding Amount Currency (in USD)] ) ), 1000 ) )
            ),
            0
        )
    VAR dp = 1
    RETURN
        ROUND (
            DIVIDE ( SUM ( [Total Funding Amount Currency (in USD)] ), 1000 ^ SafeLog ),
            dp
        )
            & SWITCH ( Safelog, 1, "K", 2, "M", 3, "bn", 4, "tn" )
    

     

     

    Reference: Auto-Format Numbers in Billions, Millions, Thousan... - Microsoft Power BI Community

     

     

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.