Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Text.PadEnd spaces getting trimmed

Hi,

 

I'm having issues with the Text.PadEnd function. It seems like Power BI trims away the spaces I want to add.

 

The function I'm using is:

Text.PadEnd([firstname], 20, " ")

 

I can see the spaces while in Power Query Editor, but as soon as I close & apply they get removed. It works if I use dots or other characters, but it's the spaces I need.

 

It keeps the spaces when I add spaces in the beginning with:

Text.PadStart([firstname], 20, " ")

 

But that's not what I'm looking foor. I need the spaces after.

 

Is there any way around this? The column [firstname] is a text field.

 

I've also tried this code as suggested in another thread:

PadText = [firstname] & REPT ( " ", 15 - LEN ( [firstname] ) )

But I get an error saying "An argument of function 'REPT' has the wrong data type or has an invalid value.". It seems that the function only works with integers.

 

Sincerely

Ash

2 ACCEPTED SOLUTIONS
mahoneypat
Employee
Employee

I reproduced your issue loading from the query editor, but this DAX column expression did work.  Is [firstname] a column or a measure?

 

WithSpaces = PadEnd[Column1] & REPT(" ", 15 - LEN(PadEnd[Column1]))

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

I created some data, used your function, and found it to work normally.

vyangliumsft_0-1625815783418.png

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi,

I can't post any data because of the GDPR and such.


I didn't get it to work so I worked around it.

 

Thanks for the help!

 

Sincerely
Ash

v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

I created some data, used your function, and found it to work normally.

vyangliumsft_0-1625815783418.png

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

mahoneypat
Employee
Employee

I reproduced your issue loading from the query editor, but this DAX column expression did work.  Is [firstname] a column or a measure?

 

WithSpaces = PadEnd[Column1] & REPT(" ", 15 - LEN(PadEnd[Column1]))

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi,

 

[firstname] is a column with text as data type. Still getting this error.

 

AshPBI_0-1625728334904.png

 

AshPBI_1-1625728588457.png

 

 

 

Sincerely
Ash

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.