PDA

View Full Version : Find Leading Spaces in Powerquery



Kirk P.
2016-11-18, 08:47 PM
I've got a text field that comes with a certain number of leading spaces.
These leading spaces indicate the level within the hierarchy, so 0 spaces is level 1, 5 spaces is level 2, 10 spaces is level 3, etc.
In Excel, this formula does a great job of reporting the number of leading spaces

=FIND(LEFT(TRIM(" LV Traditional"))," LV Traditional")-1

Is there an equivalent formula in Powerquery? I tried what I thought was the obvious Text.Start(" LV Traditional",Text.Trim(" LV Traditional"))), but it returns an error.

Bill Szysz
2016-11-19, 01:00 AM
Try something like this


Text.PositionOfAny(" LV Traditional", {"A".."Z","a".."z"})

Regards

Kirk P.
2016-11-21, 03:51 PM
Try something like this


Text.PositionOfAny(" LV Traditional", {"A".."Z","a".."z"})

Regards

Simple solution, and works great. Thanks!