Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
Hello,
I am trying to count the number of line breaks in a cell.
The Process:
Output:
Question:
I do not know how to create a formula or program to count the line breaks.
In excel the formula would be
=LEN(['Network Number'])-LEN(SUBSTITUTE(['Network Number'],CHAR(10),""))+1
I know that =Len(['Network Number']) can be written as
Text.Length([Network Number])
but I do not know where to go from here.
Pre Query Sample Data of one Row:
Network Number | Activity Hours |
71127849 70000005 | 2 |
Ideal Query Output:
Network Number | Hrs Per Network |
71127849 | 1 |
70000005 | 1 |
Solved! Go to Solution.
Hi @jalissa13
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjc0NDK3MLGMyTM3AANTJR0lI6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Network Number" = _t, #"Activity Hours" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Network Number", type text}, {"Activity Hours", Int64.Type}}),
Custom1 = Table.TransformColumns(#"Changed Type",{{"Network Number", each Text.Split(_,"#(lf)")}}),
#"Added Custom" = Table.AddColumn(Custom1, "Hrs Per Network", each [Activity Hours]/List.Count([Network Number])),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Activity Hours"}),
#"Expanded Network Number" = Table.ExpandListColumn(#"Removed Columns", "Network Number")
in
#"Expanded Network Number"
Hi @jalissa13
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjc0NDK3MLGMyTM3AANTJR0lI6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Network Number" = _t, #"Activity Hours" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Network Number", type text}, {"Activity Hours", Int64.Type}}),
Custom1 = Table.TransformColumns(#"Changed Type",{{"Network Number", each Text.Split(_,"#(lf)")}}),
#"Added Custom" = Table.AddColumn(Custom1, "Hrs Per Network", each [Activity Hours]/List.Count([Network Number])),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Activity Hours"}),
#"Expanded Network Number" = Table.ExpandListColumn(#"Removed Columns", "Network Number")
in
#"Expanded Network Number"
Hi @Vera_33 ,
This project seems to be ever growing.
It has slightly modified so I now have two columns I would like to split that are related to each other.
Example of Raw Data:
71597106 71597106 71597107 71597108 71597109 | N/A N/A N/A N/A N/A |
I copied the code from last time and edited it to match the new column "Designations".
The problem is doubling the data. Example: (note it is not always N/A sometimes it is A, B, C)
71597106 | N/A N/A N/A N/A N/A |
71597107 | N/A N/A N/A N/A N/A |
Once it splits into seperate rows again, I now have doubled (if not more) the data.
Is there a way to split them at the same time?
I think if I continue this way, the filter down part will also double the time that is summed at the end.
Nevermind I did it!
I created both columns into List and then created a table using both columns.
Then I used the same formula to split the Time by the list count.
Last I Expanded the table.
@Vera_33
Thank you so much! it worked perfectly. I am more of a button pusher on Power Query rather than a program from scratch person, so I was slightly confused on how the Custom1 was created, but it did work perfectly.
I really appreciate your quick response.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.