cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
catheprado
Regular Visitor

How to count whitespaces in the beggining of a string?

Hello, i'm trying to count the number of white spaces in the beggining of a string in Power Query...

I couldn't find a solution yet.

 

Here's an example

catheprado_0-1613689611924.png

I have to count just the whitespaces before the text. 

 

Please, help me 🙂 

Tks

1 ACCEPTED SOLUTION
ziying35
Impactful Individual
Impactful Individual

Hi, @catheprado 

Try this:

= Table.AddColumn(<YourPreviousStepName>, "space_cnt", each Text.Length([<YourColumnName>])-Text.Length(Text.TrimStart([<YourColumnName>])))

View solution in original post

1 REPLY 1
ziying35
Impactful Individual
Impactful Individual

Hi, @catheprado 

Try this:

= Table.AddColumn(<YourPreviousStepName>, "space_cnt", each Text.Length([<YourColumnName>])-Text.Length(Text.TrimStart([<YourColumnName>])))

View solution in original post

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Get Ready for Power BI Dev Camp

Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors