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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Pandadev
Post Prodigy
Post Prodigy

Power Query formula to get text after last comma if comma exist or keep text if no comma

Hi I have data stored in a column which sometimes has historic data split by a column , with latest data always after last comma.

Sometimes though there is no historic data so then I would need to keep all the data. Is there a way in data query to do this please.

Example

A22122,D46543

B11111

C22222,C22221,C22223

 

What I would need is

D46543

B11111

C22223

1 ACCEPTED SOLUTION

@Pandadev

You can then try Text After Delimiter

image.png

Use the following settings:

image.png

Cheers!
Vivek

If it helps, please mark it as a solution. Kudos would be a cherry on the top 🙂
If it doesn't, then please share a sample data along with the expected results (preferably an excel file and not an image)

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Pandadev , Try a new column like this power query

Text.End([col],Text.PositionOf([col], ";", Occurrence.Last))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

The code nearly works , but in some instances there are codes which can have different amounts of digits .

some are 5 digits , some 6 , some 7 etc. with this code , it looks like it is only giving last 6 characters .

@Pandadev

You can then try Text After Delimiter

image.png

Use the following settings:

image.png

Cheers!
Vivek

If it helps, please mark it as a solution. Kudos would be a cherry on the top 🙂
If it doesn't, then please share a sample data along with the expected results (preferably an excel file and not an image)

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

vivran22
Community Champion
Community Champion

Hello @Pandadev ,

 

You may try the following:

Add Column > Extract > Last Characters

image.png

 

Enter the number of characters (in this case, 6).

 

Hope this helps.

 

Cheers!
Vivek

If it helps, please mark it as a solution. Kudos would be a cherry on the top 🙂
If it doesn't, then please share a sample data along with the expected results (preferably an excel file and not an image)

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors