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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
kamran
Frequent Visitor

Conditionally Replace Line-Breaks with Space within the same multi-line text field

Hi folks

 

(Appologies for also posting it to wrong forum "Report Server" a while before)

 

I have a multi-line text column (equivalent to nVarchar (max) ) which is getting data from SharePoint using OData connection.

So it's limiting me to apply easy SQL on data.

Each field of this text column is having multi-line comments from end users.

 

I've tried to manipulate it using a Conditional Column in Data Model of Power BI using the below formula:

 

T_Comments = IF((find(UNICHAR(10),KeyEvaluationQuestions[ExecutiveSummary],1)+1) = find(UNICHAR(46),KeyEvaluationQuestions[ExecutiveSummary],1), KeyEvaluationQuestions[ExecutiveSummary], SUBSTITUTE(KeyEvaluationQuestions[ExecutiveSummary], UNICHAR(10)," "))

My logic was to replace all the line breaks (UNICHAR(10)) with a Space, which are not followed by a Full-Stop (UNICHAR(46)). Otherwise, it should not change the feild values.

 

But, I think, whenever the condition is true, this formula (

SUBSTITUTE(KeyEvaluationQuestions[ExecutiveSummary], UNICHAR(10)," ")

) is working on the whole one field, not replacing the line-breaks conditionally.

 

Logically it makes sense and I'm feeling the need of Loop kind of functionality in Power BI DAX,

which should iterate through the all contents of a field and work conditionally only where required.

 

Can you please suggest me what DAX function can I use here or any other suggestion?

4 REPLIES 4
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @kamran,

You should share some sample data and list expected result, so that we can help you in details. You can create some fake data if your data is private.

Best Regards,
Angelia

Thanks v-huizhn for your attention, Here is the sample data:

 

In 2017, a XYZ appointed external moderator post-moderated a large
number of assessments of the undergraduate programmes. While the overall
outcome of the post-moderation was “met” requirements, the moderator
highlighted some areas of concern that needed to be addressed urgently. The
academic team has worked closely with the School’s Management, and the
ABC and DEF combined Academic Directorate to address all issues. 

Overall, student achievement rates are excellent.

In this data, line breaks after "large" in first line, or "overall" in 2nd line or similarly in the next lines, are not acceptable. However line-break after "issues." in the 2nd last line is fine because there is a full stop (.) after the word "issues".

 

My below mentioned formula works blindly as it creates line-breaks after each Full Stop or the other way, it removes all line-breaks.

kamran
Frequent Visitor

Hi gurus...is there any solution to my below problem??

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.