Search code examples
powerquerym

How to transform List type in Power Query / M


Is there a more direct way to transform the type of the elements in a list than via Table.TransformColumnTypes (which would add an additional clumsy transformation step)?

Using List.Transform (List, each _ as text) for example will return errors for number values. Is there a correct syntax for performing that transformation directly on a list (aim is to use Text.Combine in order to concatenate the list's values)?


Solution

  • To convert a number to a text value, use Number.ToText. You can use something like this to use Text.Combine with your numeric list:

    = Text.Combine(List.Transform(List, each Number.ToText(_)), "separator")