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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
win_anthony
Resolver III
Resolver III

Removing Last Delimiter from Each Row

The goal is to remove the last comma delimiter of each row. Some rows have one item and is finalized with a comma delimiter. Some rows have multiple items separated by comma delimiters. But all rows have a comma as the final character. 

 

Any advice on how to remove the last comma delimiter of each row is greatly appreciated. Below is sample data for context. 

 

Current Output (notice the last comma of each row)

Test_Data
Black,
Black, White, Red,
Blue, Orange,
Green, Blue, Black, Red, Orange,

 

Expected Output 

Test_Data
Black
Black, White, Red
Blue, Orange
Green, Blue, Black, Red, Orange
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@win_anthony Use the Transform tab. Extract, text before delimiter. Use comma as delimiter and From the end of input and 0.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcspJTM7WUYrVgTEVwjMyS1J1FIJSU2DCpUCuf1FiXnoqRMS9KDU1T0cBIgHVBVKOUBQLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Test_Data = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Test_Data", type text}}),
    #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Changed Type", {{"Test_Data", each Text.BeforeDelimiter(_, ",", {0, RelativePosition.FromEnd}), type text}})
in
    #"Extracted Text Before Delimiter"


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@win_anthony Use the Transform tab. Extract, text before delimiter. Use comma as delimiter and From the end of input and 0.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcspJTM7WUYrVgTEVwjMyS1J1FIJSU2DCpUCuf1FiXnoqRMS9KDU1T0cBIgHVBVKOUBQLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Test_Data = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Test_Data", type text}}),
    #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Changed Type", {{"Test_Data", each Text.BeforeDelimiter(_, ",", {0, RelativePosition.FromEnd}), type text}})
in
    #"Extracted Text Before Delimiter"


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler omg I feel so stupid bc I totally knew that. Regardless, thank you for your advice.

@win_anthony No worries! You shouldn't feel stupid, we all forget stuff we have learned at some point! Happens to me all the time!



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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