set column data type firxt X and remaining

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,922
Office Version
  1. 365
Platform
  1. Windows
Hi,

Is there a way to use Table.TransformColumnTypes where instead of listing each column field value, I can have the first 11 columns as type text and the remaining columns as type number?

Below errors
Power Query:
let
    Source = Table.Transpose(Excel.CurrentWorkbook(){[Name="Output_Column_Fields"]}[Content]),
    promote_headers = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    
    col_names = Table.ColumnNames(promote_headers),
    first_11 = List.FirstN(col_names, 11),
    remainder = List.RemoveFirstN(col_names, 11),
    change_type = Table.TransformColumnTypes(promote_headers,List.Combine({first_11, remainder})),
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Please try


Power Query:
    col_type = List.Repeat({type text},11) & List.Repeat({type number}, List.Count(col_names)-11),
    change_type = Table.TransformColumnTypes(Source, List.Zip({col_names,col_type }))
 
Upvote 0
Solution

Forum statistics

Threads
1,225,608
Messages
6,185,963
Members
453,333
Latest member
BioCoder84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top