Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (11.1k points)

I had a number

ex.
12876391

and I wanted to convert into

12,876,391 

How can I do this? 

1 Answer

0 votes
by (22.5k points)
edited by

For Comma next to number use the following measure:

(n as number) as text =>
let
    numberAsTextList = Text.Split(Number.ToText(Number.Abs(n), null, "en-US"), "."),
    textWhole = numberAsTextList{0},
    fNextRecordInListGenerate = each
            let
                len = Text.Length([remaining])
            in
                if len = 0 then
                    [remaining = null]
                else
                    [remaining = Text.Start([remaining], List.Max({0, len - 3})), part = Text.End([remaining], 3)],
    nums = List.Reverse(List.Generate(
        () => fNextRecordInListGenerate([remaining = textWhole, part = ""]),
        each [remaining] <> null,
        fNextRecordInListGenerate,
        each [part]
    )),
    ret = (if Number.Sign(n) = -1 then "-" else "")
        & Text.Combine(nums, ",")
        & (if List.Count = 1 then "" else "." & numberAsTextList{1})
in
    ret

If u want to know about any Power BI Course, then sign up for this Power Bi Certification course and master the tool!

Related questions

Browse Categories

...