Text.Trim

 

This topic applies to the Power Query Formula Language which can be used with Power Query and Power BI Desktop to build queries that mashup data. See the list of function categories.

Removes any occurrence of character pattern in trimChars from text.

Text.Trim(text as nullable text, optional trimChars as any) as nullable text  

ArgumentDescription
textThe text to trim from.
optional trimCharsA character value or a list of character values.
  • Characters are removed from the beginning and end of the text value.

  • If trimChars is not specified, then whitespace characters are trimmed. Whitespace characters are defined by the Power Query formula language specification document. trimChar is either a character value or a list of character values.

Text.Trim("xyAyz", "x") equals "yAyz"  

Where: x is removed.

Text.Trim("xyAyz", {"x","y"}) equals "Ayz"  

Where: x and y are removed.

Text.Trim("xyAyz", {"x","y","z"}) equals "A"  

Where:

  1. The first x, y and z pattern is removed.

  2. AND the second x, y and z pattern is removed

Text.Trim("xyAyz", "xy") equals error  

Show: