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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

help with splitting column by delimitor only if it is in the last 4 digits

Hi All,

 

Im having issues splitting a column using the . Delimitor, What i have is a column that has Filename and Extensions in one but not all the rows have a filename. So here is the problem when i split using the . delimitor to try get a column with just extentions i also get some data where people may have used a "." in the filepath. What i want to do is split using the "." only if it is in the last 4 digits?

 

Here is code sofar:

<Code>

= Table.SplitColumn(#"Changed Type", "Column4", Splitter.SplitTextByEachDelimiter({"."}, QuoteStyle.None, true), {"Column4.1", "Column4.2"})

</Code>

7 REPLIES 7
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.

 

Best Regards

Allan

 

 

v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario.

Table:

c1.png

 

You may go to 'Query Editor'=>"Transform"=>"Split Column"=>"By Delimiter", set as below.

c2.png

 

Result:

c3.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

nandukrishnavs
Super User
Super User

@Anonymous 

Try this 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WykvMTTXUSy4uU4rVAfH0ULm5qXpgFUbGJkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Custom2" = Table.AddColumn(#"Changed Type", "Custom.2", each let lengthofText=Text.Length([Column1]),
postionOfdot=Text.PositionOf([Column1], ".", Occurrence.Last),
a= lengthofText-postionOfdot,
b= if a<=4 then Text.Middle([Column1], postionOfdot, lengthofText) else ""
in b)
in
    #"Added Custom2"

You can use below PQ in the custom column section

let
  lengthofText = Text.Length([Column1]),
  postionOfdot = Text.PositionOf([Column1], ".", Occurrence.Last),
  a = lengthofText - postionOfdot,
  b = if a <= 4 then Text.Middle([Column1], postionOfdot, lengthofText) else ""
in
  b

1.JPG2.JPG



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

Anonymous
Not applicable

Thanks i tried this and it does work, but realised that i have some extensions that is longer than the 4 characters and getting and error.

 

Any ideas how to do all extentions after the . right dot but not have the 4 character limit?

@Anonymous  Replace the 4 with expected maximum value. Or use split column ==>By Delimiter  ==> select custom(enter dot) and choose  Right-most delimiter.

Capture.JPG



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

mahoneypat
Microsoft Employee
Microsoft Employee

Here is one way to do it.  Duplicate your filename column, then use text before and text after delimiter with advanced option of From the End of the Input.  Here is an example

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WykvMTTXUSy4uU4rVAfH04NxYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Column1", "Column1 - Copy"),
#"Extracted Text Before Delimiter" = Table.TransformColumns(#"Duplicated Column", {{"Column1", each Text.BeforeDelimiter(_, ".", {0, RelativePosition.FromEnd}), type text}}),
#"Extracted Text After Delimiter" = Table.TransformColumns(#"Extracted Text Before Delimiter", {{"Column1 - Copy", each Text.AfterDelimiter(_, ".", {0, RelativePosition.FromEnd}), type text}})
in
#"Extracted Text After Delimiter"

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi,

 

Ive tried that and i keep getting Syntax Errors : Token Eof expected

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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