Forum Discussion
Power Query - Split and Trim Text at the same time
- Anonymous3 years ago
Hi JirkaZ ,
Thanks for this. It works on all the text fields, which is great. I've just used the last 2 steps, as I've amended my split to remove the number at the end of the name and use a list value instead:
#"Split Column by Delimiter - Creative" = Table.SplitColumn( #"Split Column by Delimiter - Line Item", "Taxonomy_Creative", Splitter.SplitTextByDelimiter(#"DV360 Creative - Delimiter", QuoteStyle.Csv), List.Transform(#"DV360 Creative - Fields", each Text.From(_))), MyColumns = Table.ColumnNames(#"Split Column by Delimiter - Creative"), Transformation = Table.TransformColumns(#"Split Column by Delimiter - Creative", List.Transform(MyColumns, each{_ , Text.Trim, type text})),But I have 2 date fields and a numerical field in my table. When I add in these steps, these values then show as errors. Is there any way for me to exclude these from the transformation? Or for it to only target text fields?
Thanks,
Mark
Interesting issue...
Let's try to come up with a generic approach to that.
1. The Table.SplitColumn function returns a table
2. We know that the new fields' naming convention is "OriginalColumnName".1, "OriginalColumnName".2 etc.
3. Using Table.ColumnCount we can find out how many new columns there are
4. Using Table.TransformColumns we should be able to perform the Trim (providing a column name and the desired transformation)
J.