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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
vazmor
Helper II
Helper II

Split into Column based on one row

Hello,
I have the following problem,
Based on the row where the ----- appear, you can determine a way to separate with that example into columns and assume the division of asterisks to be another sheet. Marked wih yellow
Thanks

vazmor_0-1629473764244.png

 



1 ACCEPTED SOLUTION

Hi @vazmor ,
you could count them or use this function:


 

(myTable as table, RowPosition as number, optional ColumnName as text) =>
let
ColName = if ColumnName = null then "Column1" else ColumnName,
    Source = myTable,
    #"Kept Range of Rows" = Table.Range(Source, RowPosition-1,1),
    Custom1 = Record.ToList( #"Kept Range of Rows"{0} ){0},
    Custom2 = Text.PositionOf( Custom1, " ", Occurrence.All),
    SplitPositions = {0} & Custom2,
    #"Split Column by Positions" = Table.SplitColumn(Source, ColName, Splitter.SplitTextByPositions(SplitPositions))
in
    #"Split Column by Positions"

 

It assumes that your column to split is called "Column1".
If not, pass the column name into the 3rd (optional) parameter.

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

4 REPLIES 4
ImkeF
Super User
Super User

Hi @vazmor ,
in the Split Column-dialogue, there is an option to split by positions.
It accepts a comma separated list of positions (where your blanks are) to split the table.
Just make sure to start with a 0 as a starting point.

 

ImkeF_0-1629531099020.png

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Hello, Thank you, if I can use this option but how can I use the character function based on only one row or that the position function is dynamic based on that row of the -------.

Hi @vazmor ,
you could count them or use this function:


 

(myTable as table, RowPosition as number, optional ColumnName as text) =>
let
ColName = if ColumnName = null then "Column1" else ColumnName,
    Source = myTable,
    #"Kept Range of Rows" = Table.Range(Source, RowPosition-1,1),
    Custom1 = Record.ToList( #"Kept Range of Rows"{0} ){0},
    Custom2 = Text.PositionOf( Custom1, " ", Occurrence.All),
    SplitPositions = {0} & Custom2,
    #"Split Column by Positions" = Table.SplitColumn(Source, ColName, Splitter.SplitTextByPositions(SplitPositions))
in
    #"Split Column by Positions"

 

It assumes that your column to split is called "Column1".
If not, pass the column name into the 3rd (optional) parameter.

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Thanks, 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.