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
ITManuel
Responsive Resident
Responsive Resident

How to get rid of line breaks in text

Hi,

 

I have a text in an excel file with several line breaks in it. I would like to remove all line breaks to save space.

This is the text in the excel file:

Text.png

I'm trying this code to identify line breaks, replace them with a space and then remove the spaces with trim.

VAR RemoveLineBreak =
  SUBSTITUTE ( RawText, UNICHAR ( 10 ), " " )
VAR TrimText =
  TRIM ( RemoveLineBreak )
RETURN
TrimText

 The code works to identifiy and replace the line breaks. If "A" is used instead of " " in the SUBSTITUTE function any line break is replace by an "A".

Result 1.png

 

 

 

 

 

 

 

 

 

but the result contains still all the line breaks.

Result.JPG

 

 

 

 

 

 

 

 

 

 

The strange thing is that if I replace the text in the source (excel file) while keeping all the line breaks, all line breaks are removed. 

X.JPG

 

 

 

 

 

 

 

 

With the same code as above:

Result.JPG

 

The excel file is updated via a Microsoft Query call from the ERP system. It seems that there is something in the source data which prevents the code from working. 

 

Best regards

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @ITManuel , 

 

your formula works, as you can see here, my DAX is essential the same as yours:

 

using replace = 
SUBSTITUTE( 'Table'[Text] , UNICHAR( 10 ) , " " )

 

I used SHIFT+ENTER to create the soft breaks / new lines.

 

And here is my simple table visual:

A051536A-8174-48EF-A8D1-ED2AC66B1844.jpeg

Maybe, the new line is a little bit different, and Excel is maybe a little smarter.

Maybe this article: https://en.m.wikipedia.org/wiki/Newline

provides some insights, and you may try other decimal values than 10.

 

Hopefully, this provides some insights to tackle your challenge.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

4 REPLIES 4
v-henryk-mstf
Community Support
Community Support

Hi @ITManuel ,

 

If the data provider has the latest news, please reply to the repaired result. If the problem persists, please point out.

 

Looking forward to your reply.


Best Regards,
Henry

 

Hi @v-henryk-mstf ,

 

i couldn't speak to the data provider so far, but I've seen in the meantime that the problem actually only appears in DaxStudio but not in the PBi report (with the same code).

 

This is the result of DaxStudio:

Linebreaks present in DaxStudio result.png

 

 

 

 

 

 

 

 

 

At the same time, this is the result in the PBi report:

Linebreaks removed in PBI report.png

So in the report visual itself the removal of line breaks works. When hovering over it, the appearing window still contains line breaks as the raw data and the result of DaxStudio.

 

When using tooltip, the tooltip does neither contain any line breaks.

 

I don't have any idea why, but importantly it works in the report. 🙂

 

Best regards

TomMartens
Super User
Super User

Hey @ITManuel , 

 

your formula works, as you can see here, my DAX is essential the same as yours:

 

using replace = 
SUBSTITUTE( 'Table'[Text] , UNICHAR( 10 ) , " " )

 

I used SHIFT+ENTER to create the soft breaks / new lines.

 

And here is my simple table visual:

A051536A-8174-48EF-A8D1-ED2AC66B1844.jpeg

Maybe, the new line is a little bit different, and Excel is maybe a little smarter.

Maybe this article: https://en.m.wikipedia.org/wiki/Newline

provides some insights, and you may try other decimal values than 10.

 

Hopefully, this provides some insights to tackle your challenge.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens ,

 

thank you for your response. So far I wasn't able to identify the issue, I will try to speak to the data provider to see weather he has any idea.

 

Best regards

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