Count proceeding spaces

hatstand

Well-known Member
Joined
Mar 17, 2005
Messages
778
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I have file with a hierarchal structure that I pull in using Power Query. I would like to count the proceeding spaces before each text so each row will have a figure. I can count all of the spaces but not the proceeding ones. Does anyone know of a way to do this?

Thanks.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
If you have trailing spaces or consecutive spaces mid text as well then this will not work

=LEN(text)-LEN(TRIM(text))

Single spaces between the first and last non-space characters in the text will be ignored.
 
Upvote 0
with white spaces
Text.Length(Text.TrimEnd([raw]))-Text.Length(Text.Trim([raw]))
 
Upvote 0
Thanks so much and some very handy formulas for my reference, really appreciated.
 
Upvote 0
if your text contain unwanted hard spaces you can try this
Text.Length(Text.Remove(Text.TrimEnd([raw]),Character.FromNumber(160)))-Text.Length(Text.Trim([raw]))
also you can use Text.Clean() for non-printable characters
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,266
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top