Forum Discussion
Dynamically return all column names
- Anonymous6 years ago
I hadn't noticed. Try it this way (or a differente combination of text and number :-)):
#"Changed Type"=Table.TransformColumnTypes(Source, {DynamicNameHeader{0}, type text}& List.Transform(List.Skip(DynamicNameHeader,1), each {_, type number}))
- Anonymous6 years ago
Got it!....If i just remove Columns=18, it works then...thanks for your help
Thanks ....appears to be fine for all columns except the first one which is text and not a number....any solution. Do we need to specify the type or could it be determined by BI
I hadn't noticed. Try it this way (or a differente combination of text and number :-)):
#"Changed Type"=Table.TransformColumnTypes(Source, {DynamicNameHeader{0}, type text}& List.Transform(List.Skip(DynamicNameHeader,1), each {_, type number}))
- Anonymous6 years agoNot applicable
Great thanks your suggestion worked.....one further question....any way to have the number of columns dynamic. at present im expecting 18 but this could change depending on the source. Works fine if my source has less but not sure what would happen if source data had more than 18 columns
let
Source = Csv.Document(Web.Contents("xxx"),[Delimiter=",", Columns=18, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
DynamicNameHeader = Table.ColumnNames (#"Promoted Headers"),
#"Changed Type"=Table.TransformColumnTypes(#"Promoted Headers", {DynamicNameHeader{0}, type text}& List.Transform(List.Skip(DynamicNameHeader,1), each {_, type number}))
in
#"Changed Type"- Anonymous6 years agoNot applicable
try it:
it should work for any number of columns provided that the first is numerical and the other textual.
perphs.
- Anonymous6 years agoNot applicable
No it dosnt work....i changed it to expect 8 but 18 was sent in source and only 8 displayed. Only works if the source has actually less than the expected number...in this case the expected columns are just blank