Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
M_nwadibia
Resolver III
Resolver III

add comma separator to numbers

I have a requirement to add (,) separator to 2 digit number or 3 as I have in the screen shot below. I need an expression to achieve this. Any help will be appreciated

 

M_nwadibia_1-1670531288259.png

 

 

1 ACCEPTED SOLUTION

I used the expression below to solve the comma requirements. I got the hint from the link below

=Replace(Replace(Fields!field1.Value,"1","a"),"0","b")

=Replace(Replace(Fields!Field1.Value,"Test","Test A"),"Test A B","Test C")

https://stackoverflow.com/questions/7608128/is-it-possible-to-use-one-replace-function-to-replace-mu...

View solution in original post

3 REPLIES 3
v-xiaoyan-msft
Community Support
Community Support

Hi @M_nwadibia , 

 

Please try this in Power Query editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSxBRMmZlbKMXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Column1", "Column1 - Copy"),
    #"Split Column by Position" = Table.ExpandListColumn(Table.TransformColumns(Table.TransformColumnTypes(#"Duplicated Column", {{"Column1 - Copy", type text}}, "en-US"), {{"Column1 - Copy", Splitter.SplitTextByRepeatedLengths(1), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column1 - Copy"),
    #"Grouped Rows" = Table.Group(#"Split Column by Position", {"Column1"}, {{"Count", 
each Text.Combine( [#"Column1 - Copy"],","), type nullable number}}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Grouped Rows",{{"Count", type text}})
in
    #"Changed Type2"

 

vcaitlynmstf_0-1670553180692.png

 

You may also try measure like this :

Measure =
VAR _selvalue =
    SELECTEDVALUE ( 'Table'[Column1] )
RETURN
    IF (
        LEN ( _selvalue ) > 1,
        LEFT ( _selvalue, 1 ) & ","
            & RIGHT ( _selvalue, 1 ),
        _selvalue
    )

(If you have more than 2 multi-digits, then this measure may not always meet your needs)

 

 

 

Best regards.
Community Support Team_ Caitlyn

This is in Reporting service and not Power BI. I need an expression in reporting service to achieve this.

I used the expression below to solve the comma requirements. I got the hint from the link below

=Replace(Replace(Fields!field1.Value,"1","a"),"0","b")

=Replace(Replace(Fields!Field1.Value,"Test","Test A"),"Test A B","Test C")

https://stackoverflow.com/questions/7608128/is-it-possible-to-use-one-replace-function-to-replace-mu...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.