Forum

Macro or repeated s...
 
Notifications
Clear all

Macro or repeated steps in Power Query

3 Posts
3 Users
0 Reactions
210 Views
(@cb99999)
Posts: 3
Active Member
Topic starter
 

I've got data with 50 columns.  In each one, a text string was added to the real answer wrapped in brackets.   So, for each column, I'm having to repeat my steps (select column, right click "split column", select custom and enter "]", then delete the first column).

In Excel, I'd just record a macro and run it over and over, but don't see that option in PQ.   Is there a faster, better way to run repeated actions when building your steps?

Thanks.

 
Posted : 11/05/2022 11:16 am
Alan Sidman
(@alansidman)
Posts: 222
Member Moderator
 

Look at this link for a solution to split multiple columns at once.

Power Query--Split Multiple Columns at one time | MrExcel Message Board

 
Posted : 11/05/2022 1:33 pm
Riny van Eekelen
(@riny)
Posts: 1186
Member Moderator
 

You write that the steps you need to perform repeatedly are:

1) select column,

2) right click "split column",

3) select custom and enter "]",

4) then delete the first column.

That's the same as Extract, Text After Delimiter on the Transform tab, If I'm not mistaken.

Let's say your 50-column table is called "Table1", use the following script to extract everything after the "]" in each column.

 

let
   Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
   ColNames = Table.ColumnNames (Source),
   Extract = Table.TransformColumns(Source, List.Transform (ColNames, each { _, each Text.AfterDelimiter( _, "]") }))
in
  Extract

 
Posted : 12/05/2022 3:40 am
Share: