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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PowerBI_Consult
Frequent Visitor

Transform table (fill in when missing the first two characters)

Hi,
In case there are six spaces in the beginning of my column in PowerQuery, I would like to fill them up with the same six characters as in the row above.  Below is an example:

 

PowerBI_Consult_1-1711189540607.png

What would I have to do in PowerQuery to make this happen?
Thank you for your help/feedback.

2 ACCEPTED SOLUTIONS
Joe_Barry
Responsive Resident
Responsive Resident

Hi @PowerBI_Consult 

 

  • Highlight the Column
  • In the Ribbion Add Column > Custom Column and add this 

 

if Text.Contains([Column1] , "-") then Text.BeforeDelimiter([Column1], " -") else null​

 

  • Then Highlight the new Column and go to Transform in the ribbion
  • Click on Fill and choose down. This will fill the values below
  • Add another custom column and add this 

 

if Text.Contains([Column1] , "-") then [Column1] else [Custom] & " - " & [Column1]​

 

Joe_Barry_0-1711192492158.png

 

Hope this helps

Joe

 

If you found my answer helpful and it solved your issue, please accept as solution

View solution in original post

dufoq3
Super User
Super User

Hi @PowerBI_Consult, do not post same request multiple times please. I've answered here.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

2 REPLIES 2
dufoq3
Super User
Super User

Hi @PowerBI_Consult, do not post same request multiple times please. I've answered here.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Joe_Barry
Responsive Resident
Responsive Resident

Hi @PowerBI_Consult 

 

  • Highlight the Column
  • In the Ribbion Add Column > Custom Column and add this 

 

if Text.Contains([Column1] , "-") then Text.BeforeDelimiter([Column1], " -") else null​

 

  • Then Highlight the new Column and go to Transform in the ribbion
  • Click on Fill and choose down. This will fill the values below
  • Add another custom column and add this 

 

if Text.Contains([Column1] , "-") then [Column1] else [Custom] & " - " & [Column1]​

 

Joe_Barry_0-1711192492158.png

 

Hope this helps

Joe

 

If you found my answer helpful and it solved your issue, please accept as solution

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors