title: Extract text before last space in PowerBI
body: <p>I want to extract text before the last space from column A and add it to column B.</p>
  
  <p><strong>Example of input:</strong>  </p>
  
  <p>Chicago A12</p>
  
  <p>New York GE8</p>
  
  <p>United States of America AB8</p>
  
  <p><strong>Wanted output:</strong></p>
  
  <p>Chicago</p>
  
  <p>New York</p>
  
  <p>United States of America</p>
  
  <pre><code>ColumnB = 
  VAR string_length = LEN('Data'[ColumnA])
  RETURN
  TRIM(
      LEFT(
          SUBSTITUTE('Data'[ColumnA];" "; REPT(" "; string_length));string_length)
  )
  </code></pre>
  
  <p>This does only work if I have one word before the space.</p>
  
  <p><strong>Output:</strong></p>
  
  <p>Chicago</p>
  
  <p>New</p>
  
  <p>United</p>