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
pkumarsharma
Regular Visitor

Text Splitter

I want to split text by number of characters but if at that certain position the word is not complete then take it to the end of the word. 

 

TextSplit by Number of Characters 25Increase number of characters to 26 to complete the wordNext 25 Characters to start at position 27 and go up by 24 to complete the next word before splitting
The United Nations General Assembly proclaimed 24 January as International Day of Education, in celebration of the role of education for peace and development. The right to education is enshrined in article 26 of the Universal Declaration of Human RiThe United Nations GeneraThe United Nations General Assembly proclaimed 24 
1 ACCEPTED SOLUTION
slorin
Super User
Super User

Add a new column 

Splitter.SplitTextByPositions( 
Table.Group(
Table.FromColumns({{0}&Text.PositionOf([Text]," ",Occurrence.All)},{"Position"}),
{"Position"},
{},
GroupKind.Local,
(x,y)=>if y[Position]>(x[Position]+25) then 1 else 0)
[Position])
([Text])

 

 Stéphane

View solution in original post

3 REPLIES 3
slorin
Super User
Super User

Add a new column 

Splitter.SplitTextByPositions( 
Table.Group(
Table.FromColumns({{0}&Text.PositionOf([Text]," ",Occurrence.All)},{"Position"}),
{"Position"},
{},
GroupKind.Local,
(x,y)=>if y[Position]>(x[Position]+25) then 1 else 0)
[Position])
([Text])

 

 Stéphane

Hi Stephane

Note: in above 25 is replaced with 250. I am trying to build a Twitter auto post generator which is limited by 280 characters in due to character limit of Twitter.

The above custom column produces a list. When I expand it to rows and look at the lenght of the text in some cases it goes over 250. is it possible to limit it to 250 or less

Stephane, Thanks a million times, 

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
Top Kudoed Authors