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
Anonymous
Not applicable

Can a Text Column of Comma Delimited Numbers be Totaled?

Hello,

 

I am receiving external excel data to connect and incorporate into Power BI visuals.  This external excel file has a column that lists 1 or more values delimited by comma (screen shot below).  Is there a way in Power BI to sum the delimited number values into a new column/measure?

 

Example:

Text Value Column = "1788.48, 21331.65"

Desired Column = 23120.13

Capture123.PNG

 

Thank you,

Ted

1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can add a custom column in Power Query Editor to meet your requirement:

 

List.Sum(List.Transform(List.ReplaceValue(Text.Split([Value],",")," ","",Replacer.ReplaceText),each Number.From(_)))

 

14.PNG15.PNG

 

All the queries are here:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VVDJEQQhCExlyrdFASJHLFPmn8YA7mdf9kFz+L6DxhyEKxYwzocIkUAbESpgI18/l1UQ0BOlEuPMd3DmWQhh63xYDQP0Out2Ngb17rL1dq4s16vk4KUIBVBJYl7jOy+VN3eQjHOm0tnt7HS2WO7UVHtQgEhT+6eeVLI4tGnUvrYJ/NqEVb5cVh52lfoSJg2DhOd8", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Value", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Sum(List.Transform(List.ReplaceValue(Text.Split([Value],",")," ","",Replacer.ReplaceText),each Number.From(_))))
in
    #"Added Custom"


If it doesn't meet your requirement, Please show the exact expected result based on the Tables that you have shared.


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can add a custom column in Power Query Editor to meet your requirement:

 

List.Sum(List.Transform(List.ReplaceValue(Text.Split([Value],",")," ","",Replacer.ReplaceText),each Number.From(_)))

 

14.PNG15.PNG

 

All the queries are here:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VVDJEQQhCExlyrdFASJHLFPmn8YA7mdf9kFz+L6DxhyEKxYwzocIkUAbESpgI18/l1UQ0BOlEuPMd3DmWQhh63xYDQP0Out2Ngb17rL1dq4s16vk4KUIBVBJYl7jOy+VN3eQjHOm0tnt7HS2WO7UVHtQgEhT+6eeVLI4tGnUvrYJ/NqEVb5cVh52lfoSJg2DhOd8", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Value", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Sum(List.Transform(List.ReplaceValue(Text.Split([Value],",")," ","",Replacer.ReplaceText),each Number.From(_))))
in
    #"Added Custom"


If it doesn't meet your requirement, Please show the exact expected result based on the Tables that you have shared.


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This was fantastic; registered to comment on this forum just to say how grateful I am for this, it was EXACTLY what I needed!

ChrisMendoza
Resident Rockstar
Resident Rockstar

@Anonymous -

There might be but, why not just clean it up in Power Query?

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("HcvBCQAxCETRVhbPIjOJMViL2H8bK7l9HvwqIXZuW9CPBGgB5VQYIK0lywk7oSsu0iIfHr+zvOSou3T/", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", type text}}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"Value", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Value"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Value", type number}})
in
    #"Changed Type1"

 

1p.gif






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



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.

Top Solution Authors