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
PietroFarias
Resolver II
Resolver II

Table.SplitColumn with variables number of columns

Hey guys, an aid on PowerQuery.
I use the Table.SplitColumn for split de Column. My query sometimes can have 5 columns or other times 7, or 9. Today I default 9 columns in fourth parameter, but I would like to leave this function dynamic.
Can someone help me?

1 ACCEPTED SOLUTION

Hi @PietroFarias 

 

When i do this, it works

Please see image below and attached file

 

Pietro.png


Regards
Zubair

Please try my custom visuals

View solution in original post

6 REPLIES 6
AlB
Super User
Super User

Hi @PietroFarias 

 

Maybe you can use the function Table.ColumnCount( ) to find out the number of columns in the table. Otherwise, can you please provide an example to clarify what you are trying to do?

 

 

@PietroFarias 

If I undertsand the problem correctly,

 

The fourth argument of Table.Split is optional, so you can eliminate it completely.

Lets say you have column1 to be splitted into multiple columns

 

= Table.SplitColumn(Source, "Column1", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3", "Column1.4"})


Regards
Zubair

Please try my custom visuals

I did this, but always return only the first column.

Hi @PietroFarias 

 

When i do this, it works

Please see image below and attached file

 

Pietro.png


Regards
Zubair

Please try my custom visuals

Dear Zubair,

 

Please note that this is a risky solution because not always act correctly.

This method works based on the first data of the column and if your delimiter at the first data is 2 but in another line, you have more than 2 separators it will split just by 2 columns.

Therefore, to be sure that it works correctly you must have the cell which has the most delimiter at the first line.

 

 

Hi @PietroFarias,

Maybe @ImkeF a specialist in M language can help.

Regards,
MFelix

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.